From a101487c04f9bc26290a45fbaaf413d77679f1b3 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 3 Nov 2021 23:43:41 +0100 Subject: yggdrasil-wg: ... --- modules/yggdrasil-wg/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'modules/yggdrasil-wg') diff --git a/modules/yggdrasil-wg/default.nix b/modules/yggdrasil-wg/default.nix index 55064baa..51009c8f 100644 --- a/modules/yggdrasil-wg/default.nix +++ b/modules/yggdrasil-wg/default.nix @@ -3,7 +3,10 @@ with lib; let - listenPort = 51820; + listenPort = { + "4" = 51820; + "6" = 51821; + }; wgSubnet = { "4" = "2a03:4000:52:ada:2"; "6" = "2a03:4000:52:ada:3"; @@ -90,9 +93,9 @@ let in { AllowedIPs = wgHostIPs.${family}.${other}; PublicKey = trim (readFile (mkPublicKeyPath family other)); - } // (optionalAttrs (thisHost from) (linkCfgFilterCustom opts // linkMkEndpointCfg opts)); + } // (optionalAttrs (thisHost from) (linkCfgFilterCustom opts // linkMkEndpointCfg family opts)); linkCfgFilterCustom = filterAttrs (n: _v: !(elem n ["from" "to" "endpointHost"])); - linkMkEndpointCfg = opts@{from, ...}: optionalAttrs (opts ? "endpointHost" && thisHost from) { Endpoint = "${opts.endpointHost}:${toString listenPort}"; }; + linkMkEndpointCfg = family: opts@{from, ...}: optionalAttrs (opts ? "endpointHost" && thisHost from) { Endpoint = "${opts.endpointHost}:${toString listenPort.${family}}"; }; linkToGreDev = family: opts@{from, to, ...}: let other = if thisHost from then to else from; @@ -129,7 +132,7 @@ let }; wireguardConfig = { PrivateKeyFile = config.sops.secrets."yggdrasil-wg-${family}.priv".path; - ListenPort = listenPort; + ListenPort = listenPort.${family}; }; wireguardPeers = map (opts@{to, from, ...}: { wireguardPeerConfig = linkToPeer family opts; }) hostLinks.${family}; }; -- cgit v1.2.3