2022-08-03 23:53:45 +03:00
|
|
|
{ cluster, config, ... }:
|
|
|
|
let
|
|
|
|
inherit (config.networking) hostName;
|
|
|
|
|
|
|
|
link = cluster.config.links."mesh-node-${hostName}";
|
|
|
|
|
|
|
|
mkPeer = peerName: let
|
|
|
|
peerLink = cluster.config.links."mesh-node-${peerName}";
|
|
|
|
in {
|
|
|
|
publicKey = peerLink.extra.pubKey;
|
2022-08-04 01:27:21 +03:00
|
|
|
allowedIPs = [ "${peerLink.extra.meshIp}/32" ] ++ peerLink.extra.extraRoutes;
|
2022-08-03 23:53:45 +03:00
|
|
|
endpoint = peerLink.tuple;
|
|
|
|
};
|
2022-08-05 00:25:16 +03:00
|
|
|
extraPeers = [
|
|
|
|
{
|
|
|
|
publicKey = "Veol/Yw5Nf3eZVSGynLZIuR2kvnyGynexzQ8GhdDQWo=";
|
|
|
|
allowedIPs = [ "10.1.1.151/32" ];
|
|
|
|
endpoint = "pve-etcd-node-fb2465761cf3ce658e6b410bbcf1f2db.fly.dev:51280";
|
|
|
|
}
|
|
|
|
];
|
2022-08-03 23:53:45 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
age.secrets.wireguard-key-core = {
|
|
|
|
file = link.extra.privKeyFile;
|
|
|
|
mode = "0400";
|
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
firewall = {
|
2022-08-04 01:13:59 +03:00
|
|
|
trustedInterfaces = [ "wgmesh" ];
|
2022-08-03 23:53:45 +03:00
|
|
|
allowedUDPPorts = [ link.port ];
|
|
|
|
};
|
|
|
|
|
|
|
|
wireguard = {
|
|
|
|
enable = true;
|
|
|
|
interfaces.wgmesh = {
|
|
|
|
ips = [ "${link.extra.meshIp}/24" ];
|
|
|
|
listenPort = link.port;
|
|
|
|
privateKeyFile = config.age.secrets.wireguard-key-core.path;
|
2022-08-05 00:25:16 +03:00
|
|
|
peers = map mkPeer cluster.config.services.wireguard.otherNodes.mesh ++ extraPeers;
|
2022-08-03 23:53:45 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|