mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 16:41:30 +00:00
Separate uTLS random fingerprint
This commit is contained in:
parent
3b4e811907
commit
49f568abbd
|
@ -5,6 +5,7 @@ package tls
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"os"
|
"os"
|
||||||
|
@ -159,6 +160,20 @@ func NewUTLSClient(router adapter.Router, serverAddress string, options option.O
|
||||||
return &UTLSClientConfig{&tlsConfig, id}, nil
|
return &UTLSClientConfig{&tlsConfig, id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var randomFingerprint utls.ClientHelloID
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
modernFingerprints := []utls.ClientHelloID{
|
||||||
|
utls.HelloChrome_Auto,
|
||||||
|
utls.HelloFirefox_Auto,
|
||||||
|
utls.HelloEdge_Auto,
|
||||||
|
utls.HelloSafari_Auto,
|
||||||
|
utls.HelloIOS_Auto,
|
||||||
|
utls.HelloAndroid_11_OkHttp,
|
||||||
|
}
|
||||||
|
randomFingerprint = modernFingerprints[rand.Intn(len(modernFingerprints))]
|
||||||
|
}
|
||||||
|
|
||||||
func uTLSClientHelloID(name string) (utls.ClientHelloID, error) {
|
func uTLSClientHelloID(name string) (utls.ClientHelloID, error) {
|
||||||
switch name {
|
switch name {
|
||||||
case "chrome", "":
|
case "chrome", "":
|
||||||
|
@ -178,7 +193,15 @@ func uTLSClientHelloID(name string) (utls.ClientHelloID, error) {
|
||||||
case "android":
|
case "android":
|
||||||
return utls.HelloAndroid_11_OkHttp, nil
|
return utls.HelloAndroid_11_OkHttp, nil
|
||||||
case "random":
|
case "random":
|
||||||
return utls.HelloRandomized, nil
|
return randomFingerprint, nil
|
||||||
|
case "randomized":
|
||||||
|
weights := utls.DefaultWeights
|
||||||
|
weights.TLSVersMax_Set_VersionTLS13 = 1
|
||||||
|
weights.FirstKeyShare_Set_CurveP256 = 0
|
||||||
|
randomized := utls.HelloRandomized
|
||||||
|
randomized.Seed, _ = utls.NewPRNGSeed()
|
||||||
|
randomized.Weights = &weights
|
||||||
|
return randomized, nil
|
||||||
default:
|
default:
|
||||||
return utls.ClientHelloID{}, E.New("unknown uTLS fingerprint: ", name)
|
return utls.ClientHelloID{}, E.New("unknown uTLS fingerprint: ", name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,6 +218,7 @@ Available fingerprint values:
|
||||||
* ios
|
* ios
|
||||||
* android
|
* android
|
||||||
* random
|
* random
|
||||||
|
* randomized
|
||||||
|
|
||||||
Chrome fingerprint will be used if empty.
|
Chrome fingerprint will be used if empty.
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,7 @@ uTLS 是 "crypto/tls" 的一个分支,它提供了 ClientHello 指纹识别阻
|
||||||
* ios
|
* ios
|
||||||
* android
|
* android
|
||||||
* random
|
* random
|
||||||
|
* randomized
|
||||||
|
|
||||||
默认使用 chrome 指纹。
|
默认使用 chrome 指纹。
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue