Set a random source seed to avoid ID conflicts

closes #14
closes #33
This commit is contained in:
Cameron Sparr 2018-11-06 14:30:27 +00:00
parent 28a88d0810
commit 9db3df4bca
No known key found for this signature in database
GPG Key ID: 19E67263DCB25D0F

View File

@ -83,17 +83,18 @@ func NewPinger(addr string) (*Pinger, error) {
ipv4 = false
}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
return &Pinger{
ipaddr: ipaddr,
addr: addr,
Interval: time.Second,
Timeout: time.Second * 100000,
Count: -1,
id: rand.Intn(math.MaxInt16),
id: r.Intn(math.MaxInt16),
network: "udp",
ipv4: ipv4,
Size: timeSliceLength,
Tracker: rand.Int63n(math.MaxInt64),
Tracker: r.Int63n(math.MaxInt64),
done: make(chan bool),
}, nil
}
@ -454,11 +455,11 @@ func (p *Pinger) processPacket(recv *packet) error {
return nil
}
}
outPkt := &Packet{
Nbytes: recv.nbytes,
IPAddr: p.ipaddr,
Addr: p.addr,
Addr: p.addr,
}
switch pkt := m.Body.(type) {