mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
all: use math/rand/v2 more
Updates #11058 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -22,7 +22,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
insecurerand "math/rand"
|
||||
randv2 "math/rand/v2"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -212,7 +212,7 @@ func (b *LocalBackend) domainRenewalTimeByARI(cs certStore, pair *TLSCertKeyPair
|
||||
// passed. Time is randomized per recommendation in
|
||||
// https://datatracker.ietf.org/doc/draft-ietf-acme-ari/
|
||||
start, end := ri.SuggestedWindow.Start, ri.SuggestedWindow.End
|
||||
renewTime := start.Add(time.Duration(insecurerand.Int63n(int64(end.Sub(start)))))
|
||||
renewTime := start.Add(randv2.N(end.Sub(start)))
|
||||
return renewTime, nil
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ import (
|
||||
"log"
|
||||
"maps"
|
||||
"math"
|
||||
"math/rand"
|
||||
"math/rand/v2"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
@@ -6650,12 +6650,12 @@ func pickWeighted(candidates []tailcfg.NodeView) []tailcfg.NodeView {
|
||||
|
||||
// randomRegion is a selectRegionFunc that selects a uniformly random region.
|
||||
func randomRegion(regions views.Slice[int]) int {
|
||||
return regions.At(rand.Intn(regions.Len()))
|
||||
return regions.At(rand.IntN(regions.Len()))
|
||||
}
|
||||
|
||||
// randomNode is a selectNodeFunc that returns a uniformly random node.
|
||||
func randomNode(nodes views.Slice[tailcfg.NodeView]) tailcfg.NodeView {
|
||||
return nodes.At(rand.Intn(nodes.Len()))
|
||||
return nodes.At(rand.IntN(nodes.Len()))
|
||||
}
|
||||
|
||||
// minLatencyDERPRegion returns the region with the lowest latency value given the last netcheck report.
|
||||
|
@@ -5,10 +5,10 @@ package ipnlocal
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
|
Reference in New Issue
Block a user