diff --git a/net/ping/ping.go b/net/ping/ping.go index 080f7f2..4182d77 100644 --- a/net/ping/ping.go +++ b/net/ping/ping.go @@ -49,6 +49,7 @@ func (o *PingOptions) Validate() { // 64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.344 ms // 64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.163 ms // 64 bytes from 192.168.1.1: icmp_seq=7 ttl=64 time=0.180 ms +// From 192.168.1.101 icmp_seq=1 Destination Host Unreachable // --- 192.168.1.1 ping statistics --- // 7 packets transmitted, 4 received, 42% packet loss, time 6010ms @@ -93,6 +94,10 @@ LOOP: result.Summary.AvgTime = float32(avgTime) case 8: + if "bytes" != fields[1] || "from" != fields[2] { + continue LOOP + } + seqs := strings.Split(fields[4], "=") ttls := strings.Split(fields[5], "=") times := strings.Split(fields[6], "=") @@ -189,7 +194,7 @@ LOOP: if "Request timed out." != line { continue LOOP } - result.Responses[seq] = nil + // result.Responses[seq] = nil seq = seq + 1 case 6: if "Reply" != fields[0] || "from" != fields[1] { @@ -332,6 +337,10 @@ LOOP: result.Summary.AvgTime = float32(avgTime) case 8: + if "bytes" != fields[1] || "from" != fields[2] { + continue LOOP + } + seqs := strings.Split(fields[4], "=") ttls := strings.Split(fields[5], "=") times := strings.Split(fields[6], "=")