Skip to content

Commit

Permalink
fix: 修复丢包计算错误
Browse files Browse the repository at this point in the history
如果发现丢包时,延迟设置为0
  • Loading branch information
v03413 committed Nov 18, 2022
1 parent f86c87a commit e3d5791
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions client/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func (c *Client) startPing() {
pingHost.Range(func(k, v interface{}) bool {
var lost *lostPacket

host := k.(string)
isp := k.(string)
domain := v.(string)

if host == "cm" {
if isp == "cm" {
lost = &CmLostPacket
} else if host == "cu" {
} else if isp == "cu" {
lost = &CuLostPacket
} else if host == "ct" {
} else if isp == "ct" {
lost = &CtLostPacket
} else {
return false
Expand Down Expand Up @@ -73,9 +73,15 @@ func (c *Client) startPing() {
}

stat := pinger.Statistics()
if stat.AvgRtt == 0 {

lost.Push(true)
c.pingTime.Store(isp, uint(time.Duration(0)))
return true
}

lost.Push(false)
c.pingTime.Store(host, uint(stat.AvgRtt/time.Millisecond))
c.pingTime.Store(isp, uint(stat.AvgRtt/time.Millisecond))

return true
})
Expand Down

0 comments on commit e3d5791

Please sign in to comment.