mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
Update to math/rand/v2
This commit updates the uses of math/rand to math/rand/v2, which was released in Go 1.22 (2024-02). The new package is generally safer, see https://go.dev/blog/randv2 for the details. There are no user-visible changes, it is only adjusting the name of functions, simplify some code thanks to v2 having a better API, etc.
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -76,7 +76,7 @@ func (a *Authenticator) Authenticate(tr *trace.Trace, user, domain, password str
|
||||
delay := a.AuthDuration - elapsed
|
||||
if delay > 0 {
|
||||
maxDelta := int64(float64(delay) * 0.2)
|
||||
delay += time.Duration(rand.Int63n(maxDelta))
|
||||
delay += time.Duration(rand.Int64N(maxDelta))
|
||||
time.Sleep(delay)
|
||||
}
|
||||
}(time.Now())
|
||||
|
||||
Reference in New Issue
Block a user