make natpmp module thing work
This commit is contained in:
parent
c6df96cfea
commit
d84d25bf0c
3 changed files with 31 additions and 37 deletions
|
|
@ -14,7 +14,6 @@
|
||||||
./profiles/wireguard.nix
|
./profiles/wireguard.nix
|
||||||
./profiles/restic-server.nix
|
./profiles/restic-server.nix
|
||||||
./profiles/autologin.nix
|
./profiles/autologin.nix
|
||||||
./profiles/ssh-public-port-2050.nix
|
|
||||||
|
|
||||||
inputs.impermanence.nixosModules.impermanence
|
inputs.impermanence.nixosModules.impermanence
|
||||||
inputs.stylix.nixosModules.stylix
|
inputs.stylix.nixosModules.stylix
|
||||||
|
|
@ -110,6 +109,16 @@
|
||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
|
|
||||||
|
own.natpmp-portforward = {
|
||||||
|
enable = true;
|
||||||
|
mappings = [
|
||||||
|
{
|
||||||
|
public = 2050;
|
||||||
|
local = 22;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
nixpkgs.config = {
|
nixpkgs.config = {
|
||||||
# rocmSupport = true;
|
# rocmSupport = true;
|
||||||
allowUnfreePredicate = pkg:
|
allowUnfreePredicate = pkg:
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
{pkgs, ...}: {
|
|
||||||
systemd.services.ssh-port2050-natpmp = {
|
|
||||||
bindsTo = ["sshd.socket"];
|
|
||||||
after = ["sshd.socket"];
|
|
||||||
wantedBy = ["multi-user.target"];
|
|
||||||
serviceConfig.Restart = "on-failure";
|
|
||||||
serviceConfig.ExecStart = pkgs.writeScript "ssh-port2050-natpmp" ''
|
|
||||||
#!${pkgs.bash}/bin/bash
|
|
||||||
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
${pkgs.libnatpmp}/bin/natpmpc -a 2050 22 tcp 60
|
|
||||||
${pkgs.coreutils}/bin/sleep 30
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -8,12 +8,13 @@
|
||||||
in {
|
in {
|
||||||
options.own.natpmp-portforward = {
|
options.own.natpmp-portforward = {
|
||||||
enable = lib.mkEnableOption "enable natpmp port forwarding service";
|
enable = lib.mkEnableOption "enable natpmp port forwarding service";
|
||||||
mappings = lib.types.listOf (lib.types.submodule {
|
mappings = lib.mkOption {
|
||||||
|
type = lib.types.listOf (lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
public = lib.mkOption {
|
public = lib.mkOption {
|
||||||
type = lib.types.port;
|
type = lib.types.port;
|
||||||
};
|
};
|
||||||
private = lib.mkOption {
|
local = lib.mkOption {
|
||||||
type = lib.types.port;
|
type = lib.types.port;
|
||||||
};
|
};
|
||||||
protocol = lib.mkOption {
|
protocol = lib.mkOption {
|
||||||
|
|
@ -26,6 +27,7 @@ in {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.services.natpmp-portforward = {
|
systemd.services.natpmp-portforward = {
|
||||||
|
|
@ -35,10 +37,10 @@ in {
|
||||||
ExecStart = pkgs.writeScript "natpmp-portforward" ''
|
ExecStart = pkgs.writeScript "natpmp-portforward" ''
|
||||||
#!${pkgs.bash}/bin/bash
|
#!${pkgs.bash}/bin/bash
|
||||||
|
|
||||||
"${lib.concatMapStrings (x: ''
|
${lib.concatMapStrings (x: ''
|
||||||
${pkgs.libnatpmp}/bin/natpmpc -a ${x.public} ${x.private} ${x.protocol} 60
|
${pkgs.libnatpmp}/bin/natpmpc -a ${toString x.public} ${toString x.local} ${x.protocol} 180
|
||||||
'')
|
'')
|
||||||
cfg.mappings}"
|
cfg.mappings}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue