mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 14:04:02 +03:00
Switch to rand/v2
This commit is contained in:
@@ -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,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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package faketls_test
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/hmac"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user