From 46edfe49e3c97d370729d0688755826ddc4f9a02 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Sat, 23 May 2026 13:19:37 +0000 Subject: [PATCH] fix(portforwarding): handle empty ports without panicing --- internal/portforward/service/command.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/portforward/service/command.go b/internal/portforward/service/command.go index 6233accd..2854ade7 100644 --- a/internal/portforward/service/command.go +++ b/internal/portforward/service/command.go @@ -15,7 +15,11 @@ func runCommand(ctx context.Context, cmder Cmder, logger Logger, } portsString := strings.Join(portStrings, ",") 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) return cmder.RunAndLog(ctx, commandString, logger) }