Don't oversend packets

fixes part of #6
This commit is contained in:
Cameron Sparr
2018-11-06 16:54:34 +00:00
parent 3a0b5a7d8e
commit ef3ab45e41

View File

@@ -310,6 +310,9 @@ func (p *Pinger) run() {
wg.Wait()
return
case <-interval.C:
if p.Count > 0 && p.PacketsSent >= p.Count {
continue
}
err = p.sendICMP(conn)
if err != nil {
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})
if err != nil {
fmt.Errorf("Unable to marshal data")
return fmt.Errorf("Unable to marshal data %s", err)
}
body := &icmp.Echo{
ID: p.id,