mirror of
https://github.com/qdm12/gluetun.git
synced 2026-06-19 18:04:09 +02:00
fix(portforwarding): handle empty ports without panicing
This commit is contained in:
@@ -15,7 +15,11 @@ func runCommand(ctx context.Context, cmder Cmder, logger Logger,
|
|||||||
}
|
}
|
||||||
portsString := strings.Join(portStrings, ",")
|
portsString := strings.Join(portStrings, ",")
|
||||||
commandString := strings.ReplaceAll(commandTemplate, "{{PORTS}}", portsString)
|
commandString := strings.ReplaceAll(commandTemplate, "{{PORTS}}", portsString)
|
||||||
commandString = strings.ReplaceAll(commandString, "{{PORT}}", portStrings[0])
|
var firstPort string
|
||||||
|
if len(portStrings) > 0 {
|
||||||
|
firstPort = portStrings[0]
|
||||||
|
}
|
||||||
|
commandString = strings.ReplaceAll(commandString, "{{PORT}}", firstPort)
|
||||||
commandString = strings.ReplaceAll(commandString, "{{VPN_INTERFACE}}", vpnInterface)
|
commandString = strings.ReplaceAll(commandString, "{{VPN_INTERFACE}}", vpnInterface)
|
||||||
return cmder.RunAndLog(ctx, commandString, logger)
|
return cmder.RunAndLog(ctx, commandString, logger)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user