From fd0d76cff24790194a27c8ed3ff47d83fedc8245 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 10 Oct 2021 14:11:18 +0200 Subject: yggdrasil-wg: ... --- modules/yggdrasil-wg/default.nix | 31 ++++++++++++++++++++++++++++--- modules/yggdrasil-wg/udp2raw-secret | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 modules/yggdrasil-wg/udp2raw-secret (limited to 'modules/yggdrasil-wg') diff --git a/modules/yggdrasil-wg/default.nix b/modules/yggdrasil-wg/default.nix index e7ecf709..db7780fb 100644 --- a/modules/yggdrasil-wg/default.nix +++ b/modules/yggdrasil-wg/default.nix @@ -86,7 +86,28 @@ in { systemd.services = listToAttrs (filter ({ value, ...}: value != null) (imap0 (ix: opts@{to, from, ...}: let other = if from == hostName then to else from; in nameValuePair "yggdrasil-udp2raw@${other}" (if opts ? "endpointHost" && (from == hostName || to == hostName) then { path = with pkgs; [iptables]; serviceConfig = { - ExecStart = "${pkgs.udp2raw}/bin/udp2raw ${if from == hostName then "-c -l 127.0.0.1:${toString (udp2rawPort + ix)} -r ${opts.endpointHost}:${toString (udp2rawPort + ix)}" else "-s -l 0.0.0.0:${toString (udp2rawPort + ix)} -r 127.0.0.1:${toString listenPort}"} -k tmpkey --auth-mode hmac_sha1 --raw-mode faketcp -a"; + RuntimeDirectory = ["config"]; + ExecStartPre = pkgs.writeShellScript "udp2raw-mkconfig-${other}.sh" '' + secret=$(cat ${config.sops.secrets."yggdrasil-udp2raw-secret".path}) + cat >''${RUNTIME_DIRECTORY}/udp2raw.conf <