diff --git a/client/network.go b/client/network.go index ac609b0f..d5cbf229 100644 --- a/client/network.go +++ b/client/network.go @@ -67,10 +67,10 @@ func (c *QQClient) ConnectionQualityTest() *ConnectionQualityInfo { }() go func() { defer wg.Done() - res := utils.RunICMPPingLoop(c.servers[c.currServerIndex].String(), 10) + res := utils.RunTCPPingLoop(c.servers[c.currServerIndex].String(), 10) r.ChatServerPacketLoss = res.PacketsLoss if c.highwaySession.AddrLength() > 0 { - res = utils.RunICMPPingLoop(c.highwaySession.SsoAddr[0].String(), 10) + res = utils.RunTCPPingLoop(c.highwaySession.SsoAddr[0].String(), 10) r.SrvServerPacketLoss = res.PacketsLoss } }() diff --git a/utils/icmp.go b/utils/tcping.go similarity index 82% rename from utils/icmp.go rename to utils/tcping.go index 886c3beb..4b899673 100644 --- a/utils/icmp.go +++ b/utils/tcping.go @@ -12,8 +12,8 @@ type ICMPPingResult struct { AvgTimeMill int64 } -// RunICMPPingLoop tcp 伪装的 icmp -func RunICMPPingLoop(ipport string, count int) (r ICMPPingResult) { +// RunTCPPingLoop 使用 tcp 进行 ping +func RunTCPPingLoop(ipport string, count int) (r ICMPPingResult) { r = ICMPPingResult{ PacketsSent: count, PacketsLoss: count, @@ -24,7 +24,7 @@ func RunICMPPingLoop(ipport string, count int) (r ICMPPingResult) { } durs := make([]int64, 0, count) for i := 0; i < count; i++ { - d, err := pingtcp(ipport) + d, err := tcping(ipport) if err == nil { r.PacketsLoss-- durs = append(durs, d) @@ -45,7 +45,7 @@ func RunICMPPingLoop(ipport string, count int) (r ICMPPingResult) { return } -func pingtcp(ipport string) (int64, error) { +func tcping(ipport string) (int64, error) { t := time.Now().UnixMilli() conn, err := net.DialTimeout("tcp", ipport, time.Second*2) if err != nil { diff --git a/utils/icmp_test.go b/utils/tcping_test.go similarity index 73% rename from utils/icmp_test.go rename to utils/tcping_test.go index b173b3b5..6ad4c42c 100644 --- a/utils/icmp_test.go +++ b/utils/tcping_test.go @@ -5,7 +5,7 @@ import ( ) func TestPing(t *testing.T) { - r := RunICMPPingLoop("127.0.0.1:23333", 4) + r := RunTCPPingLoop("127.0.0.1:23333", 4) if r.PacketsLoss == r.PacketsSent { t.Fatal(r) }