diff --git a/derp/derp_server.go b/derp/derp_server.go index e263a6568..2658f01c3 100644 --- a/derp/derp_server.go +++ b/derp/derp_server.go @@ -17,7 +17,7 @@ "io" "io/ioutil" "log" - "math/big" + "math/rand" "os" "runtime" "strconv" @@ -56,6 +56,10 @@ func init() { } } +func init() { + rand.Seed(time.Now().UnixNano()) +} + const ( perClientSendQueueDepth = 32 // packets buffered for sending writeTimeout = 2 * time.Second @@ -927,11 +931,7 @@ func (c *sclient) sendLoop(ctx context.Context) error { } }() - jitterMs, err := crand.Int(crand.Reader, big.NewInt(5000)) - if err != nil { - panic(err) - } - jitter := time.Duration(jitterMs.Int64()) * time.Millisecond + jitter := time.Duration(rand.Intn(5000)) * time.Millisecond keepAliveTick := time.NewTicker(keepAlive + jitter) defer keepAliveTick.Stop()