Fix uTLS randomized fingerprint

This commit is contained in:
世界 2023-03-05 13:07:26 +08:00
parent 5db3cd7781
commit d24d3b26dc
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -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)
} }