diff --git a/hosts/supernova/default.nix b/hosts/supernova/default.nix index 7e7555d..08d8807 100644 --- a/hosts/supernova/default.nix +++ b/hosts/supernova/default.nix @@ -24,9 +24,9 @@ with config.lyn.lib; { # Firmware updates: services.fwupd.enable = true; - lyn.services.wgautomesh = { + lyn.services.mkMesh = { enable = true; - enable_upnp = true; + enable_upnp_portforward = true; }; ##1##3##3##7## diff --git a/hosts/wg-gateway/default.nix b/hosts/wg-gateway/default.nix index 167b231..69ad44c 100644 --- a/hosts/wg-gateway/default.nix +++ b/hosts/wg-gateway/default.nix @@ -18,8 +18,9 @@ # network - lyn.services.wgautomesh = { + lyn.services.mkMesh = { enable = true; + enable_lan_discovery = false; }; networking.useDHCP = false; diff --git a/modules/services/wgautomesh.nix b/modules/services/mkMesh.nix similarity index 87% rename from modules/services/wgautomesh.nix rename to modules/services/mkMesh.nix index 1bb3c55..1ea7e98 100644 --- a/modules/services/wgautomesh.nix +++ b/modules/services/mkMesh.nix @@ -39,11 +39,16 @@ currentHost = meshnetwork.hosts.${config.networking.hostName}; in { opt = { - enable_upnp = lib.mkOption { + enable_upnp_portforward = lib.mkOption { type = lib.types.bool; description = "Whether to allow the wireguard port in the gateway using UPnP IGD. Necessary on some firewalls, might spam unnecessary debug messages on environments without IGD gateways."; default = false; }; + enable_lan_discovery = lib.mkOption { + type = lib.types.bool; + description = "Try to discover mesh devices on the same local network."; + default = true; + }; }; config = rec { networking.firewall = { @@ -54,7 +59,7 @@ in { ] # UPnP broadcast responses ++ ( - if cfg.enable_upnp + if cfg.enable_upnp_portforward then [1900] else [] ); @@ -77,7 +82,7 @@ in { enable = true; settings = { interfaces = - if cfg.enable_upnp + if cfg.enable_upnp_portforward then [ { name = "wg0"; @@ -88,13 +93,11 @@ in { upnp_forward_external_port = config.networking.wireguard.interfaces.wg1.listenPort; } ] - else null; + else []; peers = buildPeerlist "IPv6" meshnetwork.hosts ++ buildPeerlist "IPv4" meshnetwork.hosts; + lan_discovery = cfg.enable_lan_discovery; }; gossipSecretFile = gossip_secret_path; - - #DEBUG - logLevel = "trace"; }; }; }