This commit is contained in:
naiba 2023-03-01 23:42:39 +08:00 committed by GitHub
parent 5c9341e57e
commit 88328344e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -337,12 +337,13 @@ func handleIcmpPingTask(task *pb.Task, result *pb.TaskResult) {
err = pinger.Run() // Blocks until finished.
}
if err == nil {
if pinger.Statistics().PacketsRecv == 0 {
result.Data = "Ping 未收到回包"
} else {
result.Delay = float32(pinger.Statistics().AvgRtt.Microseconds()) / 1000.0
result.Successful = true
}
stat := pinger.Statistics()
if stat.PacketsRecv == 0 {
result.Data = "pockets recv 0"
return
}
result.Delay = float32(stat.AvgRtt.Microseconds()) / 1000.0
result.Successful = true
} else {
result.Data = err.Error()
}