Fixed manual ipv4 assignment issue

release
Matthew Salerno 1 year ago
parent e43fdd5875
commit f78dc06eb1

@ -20,7 +20,7 @@ in
with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName; with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName;
{ {
networking.extraHosts = concatStringsSep "\n" (concatLists ( concatLists (forEachAttrToList thisPeer.subnetConnections (subnetName: subnetConnection: networking.extraHosts = concatStringsSep "\n" (concatLists ( concatLists (forEachAttrToList thisPeer.subnetConnections (subnetName: subnetConnection:
forEachAttrToList subnetConnection.peerConnections (remotePeerName: peerConnection: forEach peerConnection.ipAddresses (ip: "${strings.removeSuffix "/64" ip} ${remotePeerName}.${subnetName}")) forEachAttrToList subnetConnection.peerConnections (remotePeerName: peerConnection: forEach peerConnection.ipAddresses (ip: "${cidr2ip ip} ${remotePeerName}.${subnetName}"))
)))); ))));
systemd.network = { systemd.network = {
netdevs = forEachAttr' thisPeer.subnetConnections (subnetName: subnetConnection: nameValuePair "50-${shortName subnetName}" { netdevs = forEachAttr' thisPeer.subnetConnections (subnetName: subnetConnection: nameValuePair "50-${shortName subnetName}" {
@ -37,7 +37,7 @@ with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName;
wireguardPeerConfig = { wireguardPeerConfig = {
Endpoint = "${peerConnection.endpoint.ip}:${builtins.toString peerConnection.endpoint.port}"; Endpoint = "${peerConnection.endpoint.ip}:${builtins.toString peerConnection.endpoint.port}";
PublicKey = getPeerPubKey remotePeerName; PublicKey = getPeerPubKey remotePeerName;
AllowedIPs = map (ip: cidr2ip ip + "/128") peerConnection.ipAddresses; AllowedIPs = map (ip: cidr2ip ip + (if match ".*:.*" ip != null then "/128" else "/32")) peerConnection.ipAddresses;
PresharedKeyFile = getSubnetPSKFile subnetName; PresharedKeyFile = getSubnetPSKFile subnetName;
}; };
} }

@ -19,7 +19,7 @@ in
with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName; with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName;
{ {
networking.extraHosts = concatStringsSep "\n" (concatLists ( concatLists (forEachAttrToList thisPeer.subnetConnections (subnetName: subnetConnection: networking.extraHosts = concatStringsSep "\n" (concatLists ( concatLists (forEachAttrToList thisPeer.subnetConnections (subnetName: subnetConnection:
forEachAttrToList subnetConnection.peerConnections (remotePeerName: peerConnection: forEach peerConnection.ipAddresses (ip: "${strings.removeSuffix "/64" ip} ${remotePeerName}.${subnetName}")) forEachAttrToList subnetConnection.peerConnections (remotePeerName: peerConnection: forEach peerConnection.ipAddresses (ip: "${cidr2ip ip} ${remotePeerName}.${subnetName}"))
)))); ))));
networking.wireguard = { networking.wireguard = {
interfaces = forEachAttr' thisPeer.subnetConnections (subnetName: subnetConnection: nameValuePair "${head (strings.splitString "." subnetName)}" interfaces = forEachAttr' thisPeer.subnetConnections (subnetName: subnetConnection: nameValuePair "${head (strings.splitString "." subnetName)}"
@ -32,7 +32,7 @@ with getKeyProviderFuncs keyProviders inputs intermediateConfig localPeerName;
name = remotePeerName; name = remotePeerName;
publicKey = getPeerPubKey remotePeerName; publicKey = getPeerPubKey remotePeerName;
presharedKeyFile = getSubnetPSKFile subnetName; presharedKeyFile = getSubnetPSKFile subnetName;
allowedIPs = map (ip: cidr2ip ip + "/128") peerConnection.ipAddresses; allowedIPs = map ( ip: cidr2ip ip + (if match ".*:.*" ip != null then "/128" else "/32")) peerConnection.ipAddresses;
endpoint = "${peerConnection.endpoint.ip}:${builtins.toString peerConnection.endpoint.port}"; endpoint = "${peerConnection.endpoint.ip}:${builtins.toString peerConnection.endpoint.port}";
} }
// (mergeIf peerConnection.endpoint "persistentKeepalive") // (mergeIf peerConnection.endpoint "persistentKeepalive")

Loading…
Cancel
Save