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 ipv4 = false
} }
r := rand.New(rand.NewSource(time.Now().UnixNano()))
return &Pinger{ return &Pinger{
ipaddr: ipaddr, ipaddr: ipaddr,
addr: addr, addr: addr,
Interval: time.Second, Interval: time.Second,
Timeout: time.Second * 100000, Timeout: time.Second * 100000,
Count: -1, Count: -1,
id: rand.Intn(math.MaxInt16), id: r.Intn(math.MaxInt16),
network: "udp", network: "udp",
ipv4: ipv4, ipv4: ipv4,
Size: timeSliceLength, Size: timeSliceLength,
Tracker: rand.Int63n(math.MaxInt64), Tracker: r.Int63n(math.MaxInt64),
done: make(chan bool), done: make(chan bool),
}, nil }, nil
} }