Fix icmp ping

This commit is contained in:
卖女孩的小火柴 2023-03-01 22:06:44 +08:00 committed by GitHub
parent 89e542c902
commit 64dd7b9649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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