From 6cfc25309e35d2c9873864a8b04fffa884a8b4e9 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Tue, 21 Feb 2023 15:06:05 +0800 Subject: [PATCH] Fix: rand linter `math/rand.Read` has been deprecated since Go 1.20 --- component/simple-obfs/http.go | 5 +++-- component/simple-obfs/tls.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/component/simple-obfs/http.go b/component/simple-obfs/http.go index bedf9f4..57cdec6 100644 --- a/component/simple-obfs/http.go +++ b/component/simple-obfs/http.go @@ -2,10 +2,11 @@ package obfs import ( "bytes" + "crypto/rand" "encoding/base64" "fmt" "io" - "math/rand" + mRand "math/rand" "net" "net/http" @@ -65,7 +66,7 @@ func (ho *HTTPObfs) Write(b []byte) (int, error) { randBytes := make([]byte, 16) rand.Read(randBytes) req, _ := http.NewRequest("GET", fmt.Sprintf("http://%s/", ho.host), bytes.NewBuffer(b[:])) - req.Header.Set("User-Agent", fmt.Sprintf("curl/7.%d.%d", rand.Int()%54, rand.Int()%2)) + req.Header.Set("User-Agent", fmt.Sprintf("curl/7.%d.%d", mRand.Int()%54, mRand.Int()%2)) req.Header.Set("Upgrade", "websocket") req.Header.Set("Connection", "Upgrade") req.Host = ho.host diff --git a/component/simple-obfs/tls.go b/component/simple-obfs/tls.go index 7ec7090..b3d5d1c 100644 --- a/component/simple-obfs/tls.go +++ b/component/simple-obfs/tls.go @@ -2,9 +2,9 @@ package obfs import ( "bytes" + "crypto/rand" "encoding/binary" "io" - "math/rand" "net" "time"