mirror of
https://github.com/go-ping/ping.git
synced 2025-09-01 21:38:08 +00:00
5
ping.go
5
ping.go
@@ -310,6 +310,9 @@ func (p *Pinger) run() {
|
|||||||
wg.Wait()
|
wg.Wait()
|
||||||
return
|
return
|
||||||
case <-interval.C:
|
case <-interval.C:
|
||||||
|
if p.Count > 0 && p.PacketsSent >= p.Count {
|
||||||
|
continue
|
||||||
|
}
|
||||||
err = p.sendICMP(conn)
|
err = p.sendICMP(conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("FATAL: ", err.Error())
|
fmt.Println("FATAL: ", err.Error())
|
||||||
@@ -514,7 +517,7 @@ func (p *Pinger) sendICMP(conn *icmp.PacketConn) error {
|
|||||||
|
|
||||||
data, err := json.Marshal(IcmpData{Bytes: t, Tracker: p.Tracker})
|
data, err := json.Marshal(IcmpData{Bytes: t, Tracker: p.Tracker})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("Unable to marshal data")
|
return fmt.Errorf("Unable to marshal data %s", err)
|
||||||
}
|
}
|
||||||
body := &icmp.Echo{
|
body := &icmp.Echo{
|
||||||
ID: p.id,
|
ID: p.id,
|
||||||
|
Reference in New Issue
Block a user