wg-home: re-enable keepalives

this should fix some of the flakiness i've seen when deploying moby?
This commit is contained in:
2024-11-10 16:19:07 +00:00
parent a36c1a6818
commit 2684b3c1aa
2 changed files with 22 additions and 9 deletions

View File

@@ -97,6 +97,7 @@ in
sane.vpn.wg-home = lib.mkIf cfg.routeThroughServo {
id = 51;
endpoint = config.sane.hosts.by-name."servo".wg-home.endpoint;
keepalive = true;
publicKey = config.sane.hosts.by-name."servo".wg-home.pubkey;
addrV4 = cfg.ip;
subnetV4 = "24";

View File

@@ -70,6 +70,14 @@ let
e.g. "vpn.example.com:55280"
'';
};
keepalive = mkOption {
type = types.bool;
default = false;
description = ''
whether to send periodic packets to keep the NAT alive.
this should only be needed if you want to receive unprompted inbound packets.
'';
};
publicKey = mkOption {
type = types.str;
description = ''
@@ -118,7 +126,7 @@ let
priorityFwMark = config.id + 300;
};
});
mkVpnConfig = name: { addrV4, dns, endpoint, fwmark, id, privateKeyFile, publicKey, subnetV4, ... }: {
mkVpnConfig = name: { addrV4, dns, endpoint, fwmark, id, keepalive, privateKeyFile, publicKey, subnetV4, ... }: {
assertions = [
{
assertion = (lib.count (c: c.id == id) (builtins.attrValues cfg)) == 1;
@@ -136,14 +144,18 @@ let
PrivateKeyFile = privateKeyFile;
FirewallMark = fwmark;
};
wireguardPeers = [{
AllowedIPs = [
"0.0.0.0/0"
"::/0"
];
Endpoint = endpoint;
PublicKey = publicKey;
}];
wireguardPeers = [
({
AllowedIPs = [
"0.0.0.0/0"
"::/0"
];
Endpoint = endpoint;
PublicKey = publicKey;
} // lib.optionalAttrs keepalive {
PersistentKeepalive = 25;
})
];
};
systemd.network.networks."50-${name}" = {