upnp-forward: add a timeout to the unit

especially, this lets the target die, and the timer restart, when the UPNP stuff hangs
This commit is contained in:
Colin 2023-07-31 11:06:04 +00:00
parent 7ab5cfa698
commit 1ba877b325

View File

@ -47,9 +47,11 @@ let
lib.mkIf portCfg.visibleTo.wan { lib.mkIf portCfg.visibleTo.wan {
"upnp-forward-${port}" = { "upnp-forward-${port}" = {
description = "forward port ${port} from upstream gateway to this host"; description = "forward port ${port} from upstream gateway to this host";
serviceConfig.Type = "oneshot";
restartTriggers = [(builtins.toJSON portCfg)]; restartTriggers = [(builtins.toJSON portCfg)];
serviceConfig.Type = "oneshot";
serviceConfig.TimeoutSec = "6min";
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "upnp-forwards.target" ]; wantedBy = [ "upnp-forwards.target" ];
script = script =
@ -120,9 +122,9 @@ in
systemd.timers.upnp-forwards = { systemd.timers.upnp-forwards = {
wantedBy = [ "network.target" ]; wantedBy = [ "network.target" ];
timerConfig = { timerConfig = {
OnStartupSec = "1min"; OnStartupSec = "75s";
OnCalendar = cfg.upnpRenewInterval; OnCalendar = cfg.upnpRenewInterval;
RandomizeDelaySec = "2min"; RandomizeDelaySec = "30s";
Unit = "upnp-forwards.target"; Unit = "upnp-forwards.target";
}; };
}; };