mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
fix: rename icmp to tcp
This commit is contained in:
parent
82a55321e5
commit
49cec45733
@ -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
|
||||
}
|
||||
}()
|
||||
|
@ -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 {
|
@ -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)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user