small fixes to peerlist -> endpoint generation

This commit is contained in:
Lyn 2024-11-14 01:32:43 +01:00
parent ad3d196a1e
commit 232faef5c0
2 changed files with 12 additions and 4 deletions

View file

@ -90,8 +90,8 @@ in {
type = lib.types.submodule {
options = {
public = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
type = lib.types.str;
default = "";
description = "Public IPv4 address";
};
internal = lib.mkOption {
@ -107,7 +107,8 @@ in {
type = lib.types.submodule {
options = {
public = lib.mkOption {
type = lib.types.nullOr lib.types.str;
type = lib.types.str;
default = "";
description = "Public IPv6 address";
};
internal = lib.mkOption {

View file

@ -21,7 +21,10 @@
lib.mapAttrsToList (name: host: {
pubkey = host.wg.pubkey;
#if there is no public IP, make endpoint null so wgautomesh knows it unknown
endpoint = host.${version}.public;
endpoint =
if host.${version}.public == ""
then null
else "${host.${version}.public}:${toString host.wg.port}";
address = host.${version}.internal;
})
filteredHosts;
@ -46,6 +49,7 @@ in {
privateKeyFile = "/var/lib/wireguard-keys/private";
mtu = 1420;
};
services.wgautomesh = {
enable = true;
settings = {
@ -57,6 +61,9 @@ in {
upnp_forward_external_port = wireguardPort;
};
gossipSecretFile = gossip_secret_path;
#DEBUG
logLevel = "trace";
};
};
}