mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +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() {
|
go func() {
|
||||||
defer wg.Done()
|
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
|
r.ChatServerPacketLoss = res.PacketsLoss
|
||||||
if c.highwaySession.AddrLength() > 0 {
|
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
|
r.SrvServerPacketLoss = res.PacketsLoss
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -12,8 +12,8 @@ type ICMPPingResult struct {
|
|||||||
AvgTimeMill int64
|
AvgTimeMill int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunICMPPingLoop tcp 伪装的 icmp
|
// RunTCPPingLoop 使用 tcp 进行 ping
|
||||||
func RunICMPPingLoop(ipport string, count int) (r ICMPPingResult) {
|
func RunTCPPingLoop(ipport string, count int) (r ICMPPingResult) {
|
||||||
r = ICMPPingResult{
|
r = ICMPPingResult{
|
||||||
PacketsSent: count,
|
PacketsSent: count,
|
||||||
PacketsLoss: count,
|
PacketsLoss: count,
|
||||||
@ -24,7 +24,7 @@ func RunICMPPingLoop(ipport string, count int) (r ICMPPingResult) {
|
|||||||
}
|
}
|
||||||
durs := make([]int64, 0, count)
|
durs := make([]int64, 0, count)
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
d, err := pingtcp(ipport)
|
d, err := tcping(ipport)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
r.PacketsLoss--
|
r.PacketsLoss--
|
||||||
durs = append(durs, d)
|
durs = append(durs, d)
|
||||||
@ -45,7 +45,7 @@ func RunICMPPingLoop(ipport string, count int) (r ICMPPingResult) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func pingtcp(ipport string) (int64, error) {
|
func tcping(ipport string) (int64, error) {
|
||||||
t := time.Now().UnixMilli()
|
t := time.Now().UnixMilli()
|
||||||
conn, err := net.DialTimeout("tcp", ipport, time.Second*2)
|
conn, err := net.DialTimeout("tcp", ipport, time.Second*2)
|
||||||
if err != nil {
|
if err != nil {
|
@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPing(t *testing.T) {
|
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 {
|
if r.PacketsLoss == r.PacketsSent {
|
||||||
t.Fatal(r)
|
t.Fatal(r)
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user