Allow forwarding of multiple ports

This commit is contained in:
bluepython508
2023-12-08 15:51:38 +00:00
parent 259f002a99
commit 0f79c4a85a
2 changed files with 48 additions and 29 deletions

View File

@@ -48,12 +48,16 @@
type = bool;
default = true;
};
proto = mkOption {type = proto;};
dest = mkOption {type = str;};
hostProto = mkOption {type = proto;};
port = mkOption {type = port;};
forwards = mkOption {
type = listOf (submodule {
options = {
proto = mkOption {type = proto;};
port = mkOption {type = port;};
dest = mkOption {type = str;};
};
});
};
};
config.hostProto = mkDefault config.proto;
}));
};
};
@@ -65,10 +69,7 @@
};
in
lib.mapAttrs' (hostname: {
proto,
hostProto,
port,
dest,
forwards,
enable,
...
}: let
@@ -78,7 +79,7 @@
value = {
inherit enable;
script = ''
TS_AUTHKEY=$(cat $RUNTIME_DIRECTORY/authkey) ${lib.getExe self.packages.${pkgs.system}.default} ${hostProto} ${hostname} ${toString port} ${proto} ${dest}
TS_AUTHKEY=$(cat $RUNTIME_DIRECTORY/authkey) ${lib.getExe self.packages.${pkgs.system}.default} ${hostname} ${lib.concatMapStringsSep " " ({proto, port, dest}: "${proto}:${toString port}:${dest}") forwards}
'';
wantedBy = ["multi-user.target"];
serviceConfig = {