Skip to content

Commit 64503da

Browse files
committed
Handle windows case for the node not running in network switch
1 parent d18f5f2 commit 64503da

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

cmd/network/switch.go

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"github.com/chia-network/go-modules/pkg/slogs"
1515
"github.com/spf13/cobra"
1616
"github.com/spf13/viper"
17+
18+
"github.com/chia-network/chia-tools/internal/connect"
1719
)
1820

1921
var switchCmd = &cobra.Command{
@@ -306,6 +308,10 @@ func isConnectionRefused(err error) bool {
306308
if errors.As(netErr.Err, &syscallError) {
307309
return syscallError.Syscall == "connect" && errors.Is(syscallError.Err, syscall.ECONNREFUSED)
308310
}
311+
// Handle Windows-specific case
312+
if connect.IsWindowsConnectionRefused(err) {
313+
return true
314+
}
309315
}
310316
}
311317
return false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}

0 commit comments

Comments
 (0)