9fcd7d6890
Add a new "utls" dialer type that uses the refraction-networking/utls library to mimic browser TLS fingerprints (Chrome, Firefox, Safari, etc.). - x/dialer/utls/dialer.go: Registered as "utls", mirrors the TLS dialer with Handshake() using utls.UClient() for fingerprint emulation. - x/dialer/utls/fingerprint.go: Maps string names (chrome, firefox, ios, safari, edge, randomized, golang, custom) to utls.ClientHelloID presets. - x/dialer/utls/metadata.go: Parses fingerprint from dialer metadata. - go.mod: Add github.com/refraction-networking/utls v1.8.2. The fingerprint is dialer-only metadata — the standard TLS dialer is untouched. Falls back to crypto/tls if no fingerprint is configured. Closes go-gost/gost#31
34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
package utls
|
|
|
|
import (
|
|
utls "github.com/refraction-networking/utls"
|
|
)
|
|
|
|
// fingerprintMap maps user-facing string names to uTLS ClientHelloID presets.
|
|
// Each _Auto alias automatically tracks the latest known fingerprint for that
|
|
// browser in the uTLS library.
|
|
var fingerprintMap = map[string]utls.ClientHelloID{
|
|
"chrome": utls.HelloChrome_Auto,
|
|
"firefox": utls.HelloFirefox_Auto,
|
|
"ios": utls.HelloIOS_Auto,
|
|
"safari": utls.HelloSafari_Auto,
|
|
"edge": utls.HelloEdge_Auto,
|
|
"randomized": utls.HelloRandomized,
|
|
"randomized-alpn": utls.HelloRandomizedALPN,
|
|
"randomized-noalpn": utls.HelloRandomizedNoALPN,
|
|
"golang": utls.HelloGolang,
|
|
"custom": utls.HelloCustom,
|
|
}
|
|
|
|
// GetClientHelloID returns the utls.ClientHelloID for the given fingerprint
|
|
// name. The empty string and "golang" both return ok=false, signalling the
|
|
// caller to fall through to standard crypto/tls. Unknown names also return
|
|
// ok=false.
|
|
func GetClientHelloID(name string) (utls.ClientHelloID, bool) {
|
|
if name == "" || name == "golang" {
|
|
return utls.ClientHelloID{}, false
|
|
}
|
|
id, ok := fingerprintMap[name]
|
|
return id, ok
|
|
}
|