mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-26 02:21:28 +00:00
Fix uTLS randomized fingerprint
This commit is contained in:
parent
5db3cd7781
commit
d24d3b26dc
|
@ -165,7 +165,10 @@ func NewUTLSClient(router adapter.Router, serverAddress string, options option.O
|
||||||
return &UTLSClientConfig{&tlsConfig, id}, nil
|
return &UTLSClientConfig{&tlsConfig, id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var randomFingerprint utls.ClientHelloID
|
var (
|
||||||
|
randomFingerprint utls.ClientHelloID
|
||||||
|
randomizedFingerprint utls.ClientHelloID
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
modernFingerprints := []utls.ClientHelloID{
|
modernFingerprints := []utls.ClientHelloID{
|
||||||
|
@ -176,6 +179,13 @@ func init() {
|
||||||
utls.HelloIOS_Auto,
|
utls.HelloIOS_Auto,
|
||||||
}
|
}
|
||||||
randomFingerprint = modernFingerprints[rand.Intn(len(modernFingerprints))]
|
randomFingerprint = modernFingerprints[rand.Intn(len(modernFingerprints))]
|
||||||
|
|
||||||
|
weights := utls.DefaultWeights
|
||||||
|
weights.TLSVersMax_Set_VersionTLS13 = 1
|
||||||
|
weights.FirstKeyShare_Set_CurveP256 = 0
|
||||||
|
randomizedFingerprint = utls.HelloRandomized
|
||||||
|
randomizedFingerprint.Seed, _ = utls.NewPRNGSeed()
|
||||||
|
randomizedFingerprint.Weights = &weights
|
||||||
}
|
}
|
||||||
|
|
||||||
func uTLSClientHelloID(name string) (utls.ClientHelloID, error) {
|
func uTLSClientHelloID(name string) (utls.ClientHelloID, error) {
|
||||||
|
@ -199,13 +209,7 @@ func uTLSClientHelloID(name string) (utls.ClientHelloID, error) {
|
||||||
case "random":
|
case "random":
|
||||||
return randomFingerprint, nil
|
return randomFingerprint, nil
|
||||||
case "randomized":
|
case "randomized":
|
||||||
weights := utls.DefaultWeights
|
return randomizedFingerprint, nil
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue