fix: move PersistentKeepalive from server to client in case the ip address changes

This commit is contained in:
oddlama 2023-06-01 01:24:03 +02:00
parent 836dfa9fea
commit c1fe238c75
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
2 changed files with 19 additions and 18 deletions

View file

@ -213,15 +213,11 @@
++ map (clientNode: let
clientCfg = wgCfgOf clientNode;
in {
wireguardPeerConfig =
{
PublicKey = builtins.readFile (peerPublicKeyPath clientNode);
PresharedKeyFile = config.rekey.secrets.${peerPresharedKeySecret nodeName clientNode}.path;
AllowedIPs = map (net.cidr.make 128) clientCfg.addresses;
}
// optionalAttrs clientCfg.client.keepalive {
PersistentKeepalive = 25;
};
wireguardPeerConfig = {
PublicKey = builtins.readFile (peerPublicKeyPath clientNode);
PresharedKeyFile = config.rekey.secrets.${peerPresharedKeySecret nodeName clientNode}.path;
AllowedIPs = map (net.cidr.make 128) clientCfg.addresses;
};
})
ourClientNodes
else
@ -230,15 +226,19 @@
{
wireguardPeerConfig = let
snCfg = wgCfgOf wgCfg.client.via;
in {
PublicKey = builtins.readFile (peerPublicKeyPath wgCfg.client.via);
PresharedKeyFile = config.rekey.secrets.${peerPresharedKeySecret nodeName wgCfg.client.via}.path;
Endpoint = "${snCfg.server.host}:${toString snCfg.server.port}";
# Access to the whole network is routed through our entry node.
# TODO this should add any routedAddresses on ANY server in the network, right?
# if A entries via B and only C can route 0.0.0.0/0, does that work?
AllowedIPs = networkCidrs;
};
in
{
PublicKey = builtins.readFile (peerPublicKeyPath wgCfg.client.via);
PresharedKeyFile = config.rekey.secrets.${peerPresharedKeySecret nodeName wgCfg.client.via}.path;
Endpoint = "${snCfg.server.host}:${toString snCfg.server.port}";
# Access to the whole network is routed through our entry node.
# TODO this should add any routedAddresses on ANY server in the network, right?
# if A entries via B and only C can route 0.0.0.0/0, does that work?
AllowedIPs = networkCidrs;
}
// optionalAttrs wgCfg.client.keepalive {
PersistentKeepalive = 25;
};
}
];
};