Switch to rand/v2

This commit is contained in:
9seconds
2026-02-18 10:34:31 +01:00
parent 3b03c4a90a
commit a0aabf2391
7 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ package events
import (
"context"
"math/rand"
"math/rand/v2"
"runtime"
"github.com/9seconds/mtg/v2/mtglib"
+2 -2
View File
@@ -3,7 +3,7 @@ package faketls
import (
"bytes"
"fmt"
"math/rand"
"math/rand/v2"
"github.com/9seconds/mtg/v2/essentials"
"github.com/9seconds/mtg/v2/mtglib/internal/faketls/record"
@@ -53,7 +53,7 @@ func (c *Conn) Write(p []byte) (int, error) {
lenP := len(p)
for len(p) > 0 {
chunkSize := rand.Intn(record.TLSMaxRecordSize)
chunkSize := rand.IntN(record.TLSMaxRecordSize)
if chunkSize > len(p) || chunkSize == 0 {
chunkSize = len(p)
}
+2 -2
View File
@@ -2,9 +2,9 @@ package faketls_test
import (
"bytes"
"crypto/rand"
"errors"
"io"
"math/rand"
"testing"
"github.com/9seconds/mtg/v2/internal/testlib"
@@ -123,7 +123,7 @@ func (suite *ConnTestSuite) TestWrite() {
suite.connMock.On("Write", mock.Anything).Return(0, nil)
dataToRec := make([]byte, record.TLSMaxRecordSize*2)
rand.Read(dataToRec) //nolint: staticcheck
rand.Read(dataToRec) //nolint: staticcheck, errcheck
n, err := suite.c.Write(dataToRec)
suite.NoError(err)
+2 -2
View File
@@ -6,7 +6,7 @@ import (
"crypto/sha256"
"encoding/binary"
"io"
mrand "math/rand"
mrand "math/rand/v2"
"github.com/9seconds/mtg/v2/mtglib/internal/faketls/record"
"golang.org/x/crypto/curve25519"
@@ -36,7 +36,7 @@ func SendWelcomePacket(writer io.Writer, secret []byte, clientHello ClientHello)
rec.Type = record.TypeApplicationData
rec.Version = record.Version12
if _, err := io.CopyN(&rec.Payload, rand.Reader, int64(1024+mrand.Intn(3092))); err != nil {
if _, err := io.CopyN(&rec.Payload, rand.Reader, int64(1024+mrand.IntN(3092))); err != nil {
panic(err)
}
+1 -1
View File
@@ -3,8 +3,8 @@ package faketls_test
import (
"bytes"
"crypto/hmac"
"crypto/rand"
"crypto/sha256"
"math/rand"
"testing"
"time"
+2 -2
View File
@@ -3,7 +3,7 @@ package network
import (
"context"
"fmt"
"math/rand"
"math/rand/v2"
"net/url"
"github.com/9seconds/mtg/v2/essentials"
@@ -19,7 +19,7 @@ func (l loadBalancedSocks5Dialer) Dial(network, address string) (essentials.Conn
func (l loadBalancedSocks5Dialer) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
length := len(l.dialers)
start := rand.Intn(length)
start := rand.IntN(length)
moved := false
for i := start; i != start || !moved; i = (i + 1) % length {
+1 -1
View File
@@ -3,7 +3,7 @@ package network
import (
"context"
"fmt"
"math/rand"
"math/rand/v2"
"net"
"net/http"
"sync"