瀏覽代碼

Refine randomized

But we should avoid using it unless we have to, see
https://github.com/refraction-networking/utls/pull/157#issuecomment-1417156797
RPRX 2 年之前
父節點
當前提交
f32921df30
共有 3 個文件被更改,包括 18 次插入11 次删除
  1. 1 1
      go.mod
  2. 2 2
      go.sum
  3. 15 8
      transport/internet/tls/tls.go

+ 1 - 1
go.mod

@@ -12,7 +12,7 @@ require (
 	github.com/pelletier/go-toml v1.9.5
 	github.com/pires/go-proxyproto v0.6.2
 	github.com/quic-go/quic-go v0.32.0
-	github.com/refraction-networking/utls v1.2.0
+	github.com/refraction-networking/utls v1.2.2-0.20230207151345-a75a4b484849
 	github.com/sagernet/sing v0.1.6
 	github.com/sagernet/sing-shadowsocks v0.1.1-0.20230202035033-e3123545f2f7
 	github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c

+ 2 - 2
go.sum

@@ -138,8 +138,8 @@ github.com/quic-go/qtls-go1-20 v0.1.0 h1:d1PK3ErFy9t7zxKsG3NXBJXZjp/kMLoIb3y/kV5
 github.com/quic-go/qtls-go1-20 v0.1.0/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM=
 github.com/quic-go/quic-go v0.32.0 h1:lY02md31s1JgPiiyfqJijpu/UX/Iun304FI3yUqX7tA=
 github.com/quic-go/quic-go v0.32.0/go.mod h1:/fCsKANhQIeD5l76c2JFU+07gVE3KaA0FP+0zMWwfwo=
-github.com/refraction-networking/utls v1.2.0 h1:U5f8wkij2NVinfLuJdFP3gCMwIHs+EzvhxmYdXgiapo=
-github.com/refraction-networking/utls v1.2.0/go.mod h1:NPq+cVqzH7D1BeOkmOcb5O/8iVewAsiVt2x1/eO0hgQ=
+github.com/refraction-networking/utls v1.2.2-0.20230207151345-a75a4b484849 h1:vNEcNapWFwnYJTBcVkHJa8VrdL40PNDLDbSGVY+ZV7I=
+github.com/refraction-networking/utls v1.2.2-0.20230207151345-a75a4b484849/go.mod h1:L1goe44KvhnTfctUffM2isnJpSjPlYShrhXDeZaoYKw=
 github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg=
 github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s=
 github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=

+ 15 - 8
transport/internet/tls/tls.go

@@ -12,6 +12,13 @@ import (
 
 //go:generate go run github.com/xtls/xray-core/common/errors/errorgen
 
+type Interface interface {
+	net.Conn
+	Handshake() error
+	VerifyHostname(host string) error
+	NegotiatedProtocol() (name string, mutual bool)
+}
+
 var _ buf.Writer = (*Conn)(nil)
 
 type Conn struct {
@@ -125,6 +132,13 @@ func init() {
 		}
 		i++
 	}
+	weights := utls.DefaultWeights
+	weights.TLSVersMax_Set_VersionTLS13 = 1
+	weights.FirstKeyShare_Set_CurveP256 = 0
+	randomized := utls.HelloRandomized
+	randomized.Seed, _ = utls.NewPRNGSeed()
+	randomized.Weights = &weights
+	PresetFingerprints["randomized"] = &randomized
 }
 
 func GetFingerprint(name string) (fingerprint *utls.ClientHelloID) {
@@ -154,7 +168,7 @@ var PresetFingerprints = map[string]*utls.ClientHelloID{
 	"360":        &utls.Hello360_Auto,
 	"qq":         &utls.HelloQQ_Auto,
 	"random":     nil,
-	"randomized": &utls.HelloRandomized,
+	"randomized": nil,
 }
 
 var ModernFingerprints = map[string]*utls.ClientHelloID{
@@ -203,10 +217,3 @@ var OtherFingerprints = map[string]*utls.ClientHelloID{
 	"helloios_11_1":         &utls.HelloIOS_11_1,
 	"hello360_7_5":          &utls.Hello360_7_5,
 }
-
-type Interface interface {
-	net.Conn
-	Handshake() error
-	VerifyHostname(host string) error
-	NegotiatedProtocol() (name string, mutual bool)
-}