Developing lightweight computation at the DSG edge
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LightKone
go-ping
Commits
9db3df4b
Unverified
Commit
9db3df4b
authored
Nov 06, 2018
by
Cameron Sparr
Browse files
Set a random source seed to avoid ID conflicts
closes #14 closes #33
parent
28a88d08
Changes
1
Hide whitespace changes
Inline
Side-by-side
ping.go
View file @
9db3df4b
...
...
@@ -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
:
r
and
.
Intn
(
math
.
MaxInt16
),
id
:
r
.
Intn
(
math
.
MaxInt16
),
network
:
"udp"
,
ipv4
:
ipv4
,
Size
:
timeSliceLength
,
Tracker
:
r
and
.
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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment