1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

fix: route the whole wireguard network when we are a client.

This commit is contained in:
oddlama 2023-05-20 20:58:37 +02:00
parent f95bc0eb30
commit 43b2bd1982
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
2 changed files with 9 additions and 3 deletions

View file

@ -219,8 +219,10 @@
wireguardPeerConfig = {
PublicKey = builtins.readFile (peerPublicKeyPath wgCfg.client.via);
PresharedKeyFile = config.rekey.secrets.${peerPresharedKeySecret nodeName wgCfg.client.via}.path;
# TODO this should be 0.0.0.0 if the client wants to route all traffic
AllowedIPs = serverAllowedIPs wgCfg.client.via;
# 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;
};
}
];

View file

@ -213,6 +213,10 @@ in rec {
net.cidr.merge (usedAddresses
++ concatMap (n: (wgCfgOf n).server.reservedAddresses) associatedServerNodes);
# The network spanning cidr addresses. The respective cidrv4 and cirdv6 are only
# included if they exist.
networkCidrs = filter (x: x != null) (attrValues networkAddresses);
# Appends / replaces the correct cidr length to the argument,
# so that the resulting address is in the cidr.
toNetworkAddr = addr: let
@ -245,7 +249,7 @@ in rec {
[Peer]
PublicKey = ${removeSuffix "\n" (builtins.readFile (peerPublicKeyPath serverNode))}
PresharedKey = $serverPsk
AllowedIPs = ${concatStringsSep ", " snCfg.addresses}
AllowedIPs = ${concatStringsSep ", " networkCidrs}
Endpoint = ${snCfg.server.host}:${toString snCfg.server.port}
EOF
'';