Replace redundant statement with function generator
This commit is contained in:
parent
ea5739ae2a
commit
06625139dd
@ -5,22 +5,18 @@ with lib;
|
||||
let
|
||||
cfg = config.clerie.nginx-port-forward;
|
||||
|
||||
mkServerBlock = isUDP: port: forward: ''
|
||||
server {
|
||||
listen ${port}${optionalString isUDP " udp"};
|
||||
listen [::]:${port}${optionalString isUDP " udp"};
|
||||
proxy_pass ${forward.host}:${toString forward.port};
|
||||
}
|
||||
'';
|
||||
|
||||
portForwardConf = ''
|
||||
stream {
|
||||
${ concatStringsSep "\n" ( mapAttrsToList ( port: forward: ''
|
||||
server {
|
||||
listen ${port};
|
||||
listen [::]:${port};
|
||||
proxy_pass ${forward.host}:${toString forward.port};
|
||||
}
|
||||
'' ) cfg.tcpPorts ) }
|
||||
${ concatStringsSep "\n" ( mapAttrsToList ( port: forward: ''
|
||||
server {
|
||||
listen ${port} udp;
|
||||
listen [::]:${port} udp;
|
||||
proxy_pass ${forward.host}:${toString forward.port};
|
||||
}
|
||||
'' ) cfg.udpPorts ) }
|
||||
${ concatStringsSep "\n" (mapAttrsToList (mkServerBlock false) cfg.tcpPorts) }
|
||||
${ concatStringsSep "\n" (mapAttrsToList (mkServerBlock true) cfg.udpPorts) }
|
||||
}
|
||||
'';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user