File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ import (
14
14
"github.com/chia-network/go-modules/pkg/slogs"
15
15
"github.com/spf13/cobra"
16
16
"github.com/spf13/viper"
17
+
18
+ "github.com/chia-network/chia-tools/internal/connect"
17
19
)
18
20
19
21
var switchCmd = & cobra.Command {
@@ -304,7 +306,13 @@ func isConnectionRefused(err error) bool {
304
306
if netErr .Op == "dial" {
305
307
var syscallError * os.SyscallError
306
308
if errors .As (netErr .Err , & syscallError ) {
307
- return syscallError .Syscall == "connect" && errors .Is (syscallError .Err , syscall .ECONNREFUSED )
309
+ if syscallError .Syscall == "connect" && errors .Is (syscallError .Err , syscall .ECONNREFUSED ) {
310
+ return true
311
+ }
312
+ // Handle Windows-specific case
313
+ if connect .IsWindowsConnectionRefused (err ) {
314
+ return true
315
+ }
308
316
}
309
317
}
310
318
}
Original file line number Diff line number Diff line change
1
+ //go:build !windows
2
+
3
+ package connect
4
+
5
+ // IsWindowsConnectionRefused is a no-op on non-Windows systems.
6
+ func IsWindowsConnectionRefused (err error ) bool {
7
+ return false
8
+ }
Original file line number Diff line number Diff line change
1
+ //go:build windows
2
+
3
+ package connect
4
+
5
+ import (
6
+ "errors"
7
+
8
+ "golang.org/x/sys/windows"
9
+ )
10
+
11
+ // IsWindowsConnectionRefused checks if the error is a Windows-specific connection refused error.
12
+ func IsWindowsConnectionRefused (err error ) bool {
13
+ return errors .Is (err , windows .WSAECONNREFUSED )
14
+ }
You can’t perform that action at this time.
0 commit comments