diff --git a/keys/wg.mullvad-nl3.key b/keys/wg.mullvad-nl3.key new file mode 100644 index 0000000..91584a6 Binary files /dev/null and b/keys/wg.mullvad-nl3.key differ diff --git a/keys/wg.zazu.key b/keys/wg.zazu.key new file mode 100644 index 0000000..ea44d6a Binary files /dev/null and b/keys/wg.zazu.key differ diff --git a/services/torrent-wg.nix b/services/torrent-wg.nix new file mode 100644 index 0000000..fca2c77 --- /dev/null +++ b/services/torrent-wg.nix @@ -0,0 +1,37 @@ +{lib, config, ...}: +let + cfg = config.services.yorick.torrent-vpn; +in +{ + options.services.yorick.torrent-vpn = with lib; { + enable = mkEnableOption "torrent-vpn"; + name = mkOption { type = types.str; }; + namespace = mkOption { type = types.str; }; + }; + config = { + deployment.keyys = [ (+"/wg.${cfg.name}.key") ]; + networking.wireguard.interfaces.${cfg.name} = { + # curl -s https://api.mullvad.net/www/relays/all/ | jq '.[] | select(.type == "wireguard" and .country_code == "nl")' + ips = ["10.64.19.76/32" "fc00:bbbb:bbbb:bb01::1:134b/128"]; + privateKeyFile = "/root/keys/wg.${cfg.name}.key"; + peers = [{ + publicKey = "hnRyse6QxPPcZOoSwRsHUtK1W+APWXnIoaDTmH6JsHQ="; + allowedIPs = ["0.0.0.0/0" "::0/0"]; + endpoint = "185.65.134.224:31173"; + }]; + interfaceNamespace = cfg.namespace; + }; + systemd.services."wireguard-${cfg.name}" = { + preStart = '' + ip netns add "${cfg.namespace}" + ''; + postStop = '' + ip netns del "${cfg.namespace}" + ''; + }; + environment.etc."netns/torrent/resolv.conf".text = '' + nameserver 193.138.218.74 + ''; + }; +} +# todo: presets