From f32921df307d80063fddcd5e6aa11d95f57f394e Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 8 Feb 2023 14:51:15 +0800 Subject: [PATCH] Refine randomized But we should avoid using it unless we have to, see https://github.com/refraction-networking/utls/pull/157#issuecomment-1417156797 --- go.mod | 2 +- go.sum | 4 ++-- transport/internet/tls/tls.go | 23 +++++++++++++++-------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 021bd587..b292f17e 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index 9488b187..23d380e8 100644 --- a/go.sum +++ b/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= diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index b3cde801..1a880b98 100644 --- a/transport/internet/tls/tls.go +++ b/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) -}