Skip to content

Commit a6fd4de

Browse files
Copilotscaryrawr
andcommitted
Add Windows compatibility check for SSH multiplexing
Skip SSH multiplexing on Windows due to potential compatibility issues with OpenSSH's ControlMaster/ControlPath implementation. On Windows, BuildSSHMultiplexArgs now returns an empty slice, allowing the extension to work without multiplexing on that platform. - Add runtime.GOOS check to detect Windows - Return empty args slice on Windows to disable multiplexing - Add test to verify platform-specific behavior - Multiplexing still works on Linux/macOS as before Co-authored-by: scaryrawr <661373+scaryrawr@users.noreply.github.com>
1 parent d91bd6a commit a6fd4de

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

args.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8+
"runtime"
89
"strings"
910
)
1011

@@ -179,7 +180,14 @@ func sanitizeCodespaceNameForControl(name string) string {
179180
}
180181

181182
// BuildSSHMultiplexArgs builds SSH multiplexing arguments for a given control path and mode
183+
// On Windows, SSH multiplexing may not be fully supported, so this returns an empty slice
182184
func BuildSSHMultiplexArgs(controlPath string, isMaster bool) []string {
185+
// Skip SSH multiplexing on Windows due to potential compatibility issues
186+
// with OpenSSH's ControlMaster/ControlPath implementation
187+
if runtime.GOOS == "windows" {
188+
return []string{}
189+
}
190+
183191
var args []string
184192

185193
if isMaster {

args_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"runtime"
67
"strings"
78
"testing"
89
)
@@ -434,3 +435,55 @@ func TestSanitizeCodespaceNameForControl(t *testing.T) {
434435
})
435436
}
436437
}
438+
439+
// TestBuildSSHMultiplexArgsWindows tests that multiplexing is disabled on Windows
440+
func TestBuildSSHMultiplexArgsWindows(t *testing.T) {
441+
// This test verifies the behavior on different platforms
442+
controlPath := "/tmp/test-socket"
443+
444+
// Get args for both master and slave
445+
masterArgs := BuildSSHMultiplexArgs(controlPath, true)
446+
slaveArgs := BuildSSHMultiplexArgs(controlPath, false)
447+
448+
// On Windows, both should return empty slices
449+
// On other platforms, they should contain multiplexing options
450+
if runtime.GOOS == "windows" {
451+
if len(masterArgs) != 0 {
452+
t.Errorf("On Windows, BuildSSHMultiplexArgs(master) should return empty slice, got %v", masterArgs)
453+
}
454+
if len(slaveArgs) != 0 {
455+
t.Errorf("On Windows, BuildSSHMultiplexArgs(slave) should return empty slice, got %v", slaveArgs)
456+
}
457+
} else {
458+
// On non-Windows platforms, verify multiplexing args are present
459+
if len(masterArgs) == 0 {
460+
t.Error("On non-Windows platforms, BuildSSHMultiplexArgs(master) should return multiplexing args")
461+
}
462+
if len(slaveArgs) == 0 {
463+
t.Error("On non-Windows platforms, BuildSSHMultiplexArgs(slave) should return multiplexing args")
464+
}
465+
466+
// Verify ControlMaster settings
467+
foundMaster := false
468+
for _, arg := range masterArgs {
469+
if arg == "ControlMaster=auto" {
470+
foundMaster = true
471+
break
472+
}
473+
}
474+
if !foundMaster {
475+
t.Error("Master args should contain ControlMaster=auto on non-Windows platforms")
476+
}
477+
478+
foundNo := false
479+
for _, arg := range slaveArgs {
480+
if arg == "ControlMaster=no" {
481+
foundNo = true
482+
break
483+
}
484+
}
485+
if !foundNo {
486+
t.Error("Slave args should contain ControlMaster=no on non-Windows platforms")
487+
}
488+
}
489+
}

0 commit comments

Comments
 (0)