Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ func (e *RealSSHExecutor) Execute(ctx context.Context, name string, tunnel confi

func (e *RealSSHExecutor) executePortSSH(ctx context.Context, tunnelName string, tunnel config.Tunnel, portMapping string) error {
// Build SSH command for this specific port
args := []string{"-N"}
args := []string{
"-o", "ServerAliveInterval=60",
"-o", "ExitOnForwardFailure=yes",
"-N",
}

ports := expandPort(portMapping, ":")
local, remote := ports[0], ports[1]
Expand Down Expand Up @@ -151,7 +155,13 @@ type MockSSHExecutor struct {
}

func (m *MockSSHExecutor) Execute(ctx context.Context, name string, tunnel config.Tunnel) error {
args := []string{"ssh", "-N"}
args := []string{
"ssh",
"-o", "ServerAliveInterval=60",
"-o", "ExitOnForwardFailure=yes",
"-N",
}

for _, portMapping := range tunnel.Ports {
ports := expandPort(portMapping, ":")
local, remote := ports[0], ports[1]
Expand Down
18 changes: 15 additions & 3 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,20 @@ func TestMockSSHExecutor(t *testing.T) {
cmd := mock.Commands[0]
cmdStr := strings.Join(cmd, " ")

if !strings.Contains(cmdStr, "ssh -N") {
t.Error("Command should contain 'ssh -N'")
if !strings.Contains(cmdStr, "ssh") {
t.Error("Command should contain 'ssh'")
}

if !strings.Contains(cmdStr, "-N") {
t.Error("Command should contain '-N'")
}

if !strings.Contains(cmdStr, "-o ServerAliveInterval=60") {
t.Error("Command should contain '-o ServerAliveInterval=60'")
}

if !strings.Contains(cmdStr, "-o ExitOnForwardFailure=yes") {
t.Error("Command should contain '-o ExitOnForwardFailure=yes'")
}

if !strings.Contains(cmdStr, "-L 8080:localhost:8080") {
Expand Down Expand Up @@ -149,4 +161,4 @@ func TestExpandPort(t *testing.T) {
t.Errorf("For %s: expected %v, got %v", tt.input, tt.expected, result)
}
}
}
}