forked from quic-go/quic-go
switch from math/rand to math/rand/v2 (#5045)
* switch from math/rand to math/rand/v2 * switch away from golang.org/x/exp/rand
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"log"
|
||||
"math"
|
||||
mrand "math/rand/v2"
|
||||
"net/netip"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/rand"
|
||||
|
||||
"github.com/quic-go/quic-go/fuzzing/internal/helper"
|
||||
"github.com/quic-go/quic-go/fuzzing/transportparameters"
|
||||
"github.com/quic-go/quic-go/internal/protocol"
|
||||
@@ -21,8 +21,8 @@ func getRandomData(l int) []byte {
|
||||
}
|
||||
|
||||
func getRandomValue() uint64 {
|
||||
maxVals := []int64{math.MaxUint8 / 4, math.MaxUint16 / 4, math.MaxUint32 / 4, math.MaxUint64 / 4}
|
||||
return uint64(rand.Int63n(maxVals[int(rand.Int31n(4))]))
|
||||
maxVals := []uint64{math.MaxUint8 / 4, math.MaxUint16 / 4, math.MaxUint32 / 4, math.MaxUint64 / 4}
|
||||
return mrand.Uint64N(maxVals[mrand.IntN(4)])
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -41,22 +41,22 @@ func main() {
|
||||
MaxIdleTimeout: time.Duration(getRandomValue()),
|
||||
ActiveConnectionIDLimit: getRandomValue() + 2,
|
||||
}
|
||||
if rand.Int()%2 == 0 {
|
||||
tp.OriginalDestinationConnectionID = protocol.ParseConnectionID(getRandomData(rand.Intn(21)))
|
||||
if mrand.IntN(2) == 0 {
|
||||
tp.OriginalDestinationConnectionID = protocol.ParseConnectionID(getRandomData(mrand.IntN(21)))
|
||||
}
|
||||
if rand.Int()%2 == 0 {
|
||||
tp.InitialSourceConnectionID = protocol.ParseConnectionID(getRandomData(rand.Intn(21)))
|
||||
if mrand.IntN(2) == 0 {
|
||||
tp.InitialSourceConnectionID = protocol.ParseConnectionID(getRandomData(mrand.IntN(21)))
|
||||
}
|
||||
if rand.Int()%2 == 0 {
|
||||
connID := protocol.ParseConnectionID(getRandomData(rand.Intn(21)))
|
||||
if mrand.IntN(2) == 0 {
|
||||
connID := protocol.ParseConnectionID(getRandomData(mrand.IntN(21)))
|
||||
tp.RetrySourceConnectionID = &connID
|
||||
}
|
||||
if rand.Int()%2 == 0 {
|
||||
if mrand.IntN(2) == 0 {
|
||||
var token protocol.StatelessResetToken
|
||||
rand.Read(token[:])
|
||||
tp.StatelessResetToken = &token
|
||||
}
|
||||
if rand.Int()%2 == 0 {
|
||||
if mrand.IntN(2) == 0 {
|
||||
var token protocol.StatelessResetToken
|
||||
rand.Read(token[:])
|
||||
var ip4 [4]byte
|
||||
@@ -64,17 +64,17 @@ func main() {
|
||||
var ip6 [16]byte
|
||||
rand.Read(ip6[:])
|
||||
tp.PreferredAddress = &wire.PreferredAddress{
|
||||
IPv4: netip.AddrPortFrom(netip.AddrFrom4(ip4), uint16(rand.Int())),
|
||||
IPv6: netip.AddrPortFrom(netip.AddrFrom16(ip6), uint16(rand.Int())),
|
||||
ConnectionID: protocol.ParseConnectionID(getRandomData(rand.Intn(21))),
|
||||
IPv4: netip.AddrPortFrom(netip.AddrFrom4(ip4), uint16(mrand.Int())),
|
||||
IPv6: netip.AddrPortFrom(netip.AddrFrom16(ip6), uint16(mrand.Int())),
|
||||
ConnectionID: protocol.ParseConnectionID(getRandomData(mrand.IntN(21))),
|
||||
StatelessResetToken: token,
|
||||
}
|
||||
}
|
||||
|
||||
var data []byte
|
||||
if rand.Int()%2 == 0 {
|
||||
if mrand.Int()%2 == 0 {
|
||||
pers := protocol.PerspectiveServer
|
||||
if rand.Int()%2 == 0 {
|
||||
if mrand.Int()%2 == 0 {
|
||||
pers = protocol.PerspectiveClient
|
||||
}
|
||||
data = tp.Marshal(pers)
|
||||
|
||||
Reference in New Issue
Block a user