Skip to content

Commit c125afd

Browse files
committed
fix: use netErr.Timeout() to check for timeout
1 parent 80fb1a6 commit c125afd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backend/networking/ping.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ func CheckPort(host string, port string) (bool, error) {
8080
// treat "host unreachable" and "timeout" as no error
8181
var netErr *net.OpError
8282
if errors.As(err, &netErr) {
83-
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) || errors.Is(netErr.Err, os.ErrDeadlineExceeded) {
83+
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) {
84+
return false, nil
85+
}
86+
if netErr.Timeout() {
8487
return false, nil
8588
}
8689
}

0 commit comments

Comments
 (0)