File tree 4 files changed +11
-9
lines changed
4 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,6 @@ require (
62
62
go.uber.org/mock v0.5.0
63
63
go.uber.org/zap v1.27.0
64
64
golang.org/x/crypto v0.33.0
65
- golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac
66
65
golang.org/x/sync v0.11.0
67
66
golang.org/x/sys v0.30.0
68
67
golang.org/x/tools v0.30.0
@@ -127,6 +126,7 @@ require (
127
126
github.com/wlynxg/anet v0.0.5 // indirect
128
127
go.uber.org/dig v1.18.0 // indirect
129
128
go.uber.org/multierr v1.11.0 // indirect
129
+ golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
130
130
golang.org/x/mod v0.23.0 // indirect
131
131
golang.org/x/net v0.35.0 // indirect
132
132
golang.org/x/text v0.22.0 // indirect
Original file line number Diff line number Diff line change 8
8
"sync"
9
9
"time"
10
10
11
+ "math/rand/v2"
12
+
11
13
logging "github.com/ipfs/go-log/v2"
12
14
"github.com/libp2p/go-libp2p/core/event"
13
15
"github.com/libp2p/go-libp2p/core/host"
@@ -16,7 +18,6 @@ import (
16
18
"github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pb"
17
19
ma "github.com/multiformats/go-multiaddr"
18
20
manet "github.com/multiformats/go-multiaddr/net"
19
- "golang.org/x/exp/rand"
20
21
)
21
22
22
23
const (
@@ -211,7 +212,7 @@ func (p *peersMap) GetRand() peer.ID {
211
212
if len (p .peers ) == 0 {
212
213
return ""
213
214
}
214
- return p .peers [rand .Intn (len (p .peers ))]
215
+ return p .peers [rand .IntN (len (p .peers ))]
215
216
}
216
217
217
218
func (p * peersMap ) Put (pid peer.ID ) {
Original file line number Diff line number Diff line change @@ -8,13 +8,14 @@ import (
8
8
"sync"
9
9
"time"
10
10
11
+ "math/rand/v2"
12
+
11
13
"github.com/libp2p/go-libp2p/core/host"
12
14
"github.com/libp2p/go-libp2p/core/network"
13
15
"github.com/libp2p/go-libp2p/core/peer"
14
16
"github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pb"
15
17
"github.com/libp2p/go-msgio/pbio"
16
18
ma "github.com/multiformats/go-multiaddr"
17
- "golang.org/x/exp/rand"
18
19
)
19
20
20
21
// client implements the client for making dial requests for AutoNAT v2. It verifies successful
Original file line number Diff line number Diff line change @@ -9,13 +9,13 @@ import (
9
9
"crypto/elliptic"
10
10
"crypto/rand"
11
11
"crypto/x509"
12
- "encoding/binary"
13
12
"errors"
14
13
"fmt"
15
14
"net"
16
15
"time"
17
16
18
- mrand "golang.org/x/exp/rand"
17
+ mrand "math/rand/v2"
18
+
19
19
"google.golang.org/protobuf/proto"
20
20
21
21
"github.com/libp2p/go-libp2p/core/connmgr"
@@ -420,15 +420,15 @@ func genUfrag() string {
420
420
uFragLength = len (uFragPrefix ) + uFragIdLength
421
421
)
422
422
423
- seed := [8 ]byte {}
423
+ seed := [32 ]byte {}
424
424
rand .Read (seed [:])
425
- r := mrand .New (mrand .NewSource ( binary . BigEndian . Uint64 (seed [:] )))
425
+ r := mrand .New (mrand .New ( mrand . NewChaCha8 (seed )))
426
426
b := make ([]byte , uFragLength )
427
427
for i := 0 ; i < len (uFragPrefix ); i ++ {
428
428
b [i ] = uFragPrefix [i ]
429
429
}
430
430
for i := len (uFragPrefix ); i < uFragLength ; i ++ {
431
- b [i ] = uFragAlphabet [r .Intn (len (uFragAlphabet ))]
431
+ b [i ] = uFragAlphabet [r .IntN (len (uFragAlphabet ))]
432
432
}
433
433
return string (b )
434
434
}
You can’t perform that action at this time.
0 commit comments