From b8fde018ee794421e23f17108e4762be2796c4c3 Mon Sep 17 00:00:00 2001 From: wangbin Date: Wed, 9 Jul 2025 14:08:56 +0800 Subject: [PATCH] ping --- Common/commonfunc.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Common/commonfunc.go b/Common/commonfunc.go index 070fa84..11b0595 100644 --- a/Common/commonfunc.go +++ b/Common/commonfunc.go @@ -1040,10 +1040,9 @@ func GetAvailableEndpoint() string { } func IsIPReachable(ip string, port string) bool { - conn, err := net.DialTimeout("tcp", ip+":"+port, 10*time.Millisecond) - if err != nil { - return false + cmd := exec.Command("ping", "-c", "1", "-W", "1", ip) + if err := cmd.Run(); err == nil { + return true } - defer conn.Close() - return true + return false }