mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 13:54:02 +03:00
Switch to rand/v2
This commit is contained in:
@@ -2,7 +2,7 @@ package events
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"math/rand"
|
"math/rand/v2"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/v2/mtglib"
|
"github.com/9seconds/mtg/v2/mtglib"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package faketls
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand/v2"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/v2/essentials"
|
"github.com/9seconds/mtg/v2/essentials"
|
||||||
"github.com/9seconds/mtg/v2/mtglib/internal/faketls/record"
|
"github.com/9seconds/mtg/v2/mtglib/internal/faketls/record"
|
||||||
@@ -53,7 +53,7 @@ func (c *Conn) Write(p []byte) (int, error) {
|
|||||||
lenP := len(p)
|
lenP := len(p)
|
||||||
|
|
||||||
for len(p) > 0 {
|
for len(p) > 0 {
|
||||||
chunkSize := rand.Intn(record.TLSMaxRecordSize)
|
chunkSize := rand.IntN(record.TLSMaxRecordSize)
|
||||||
if chunkSize > len(p) || chunkSize == 0 {
|
if chunkSize > len(p) || chunkSize == 0 {
|
||||||
chunkSize = len(p)
|
chunkSize = len(p)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package faketls_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/v2/internal/testlib"
|
"github.com/9seconds/mtg/v2/internal/testlib"
|
||||||
@@ -123,7 +123,7 @@ func (suite *ConnTestSuite) TestWrite() {
|
|||||||
suite.connMock.On("Write", mock.Anything).Return(0, nil)
|
suite.connMock.On("Write", mock.Anything).Return(0, nil)
|
||||||
|
|
||||||
dataToRec := make([]byte, record.TLSMaxRecordSize*2)
|
dataToRec := make([]byte, record.TLSMaxRecordSize*2)
|
||||||
rand.Read(dataToRec) //nolint: staticcheck
|
rand.Read(dataToRec) //nolint: staticcheck, errcheck
|
||||||
|
|
||||||
n, err := suite.c.Write(dataToRec)
|
n, err := suite.c.Write(dataToRec)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"io"
|
"io"
|
||||||
mrand "math/rand"
|
mrand "math/rand/v2"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/v2/mtglib/internal/faketls/record"
|
"github.com/9seconds/mtg/v2/mtglib/internal/faketls/record"
|
||||||
"golang.org/x/crypto/curve25519"
|
"golang.org/x/crypto/curve25519"
|
||||||
@@ -36,7 +36,7 @@ func SendWelcomePacket(writer io.Writer, secret []byte, clientHello ClientHello)
|
|||||||
rec.Type = record.TypeApplicationData
|
rec.Type = record.TypeApplicationData
|
||||||
rec.Version = record.Version12
|
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)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package faketls_test
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"math/rand"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package network
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand/v2"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/v2/essentials"
|
"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) {
|
func (l loadBalancedSocks5Dialer) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
|
||||||
length := len(l.dialers)
|
length := len(l.dialers)
|
||||||
start := rand.Intn(length)
|
start := rand.IntN(length)
|
||||||
moved := false
|
moved := false
|
||||||
|
|
||||||
for i := start; i != start || !moved; i = (i + 1) % length {
|
for i := start; i != start || !moved; i = (i + 1) % length {
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package network
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand/v2"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
|||||||
Reference in New Issue
Block a user