Skip to content

Commit

Permalink
Support more popular browser fingerprints with utls v1.1.3.
Browse files Browse the repository at this point in the history
`fingerprint` option now supports `Edge`, `Safari`, `360Browser`, and
`QQBrowser`, in addition to the existing `Chrome`, `Firefox`, and
`iOS` options.

Thanks to uTLS developers @hwh33 and @gaukas.
  • Loading branch information
gfw-report committed Oct 12, 2022
1 parent eeccfd8 commit d135694
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/go-sql-driver/mysql v1.6.0
github.com/refraction-networking/utls v1.1.2
github.com/refraction-networking/utls v1.1.3
github.com/shadowsocks/go-shadowsocks2 v0.1.5
github.com/smartystreets/goconvey v1.6.4
github.com/stretchr/testify v1.7.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Expand Up @@ -83,6 +83,8 @@ github.com/refraction-networking/utls v0.0.0-20210713165636-0b2885c8c0d4 h1:n9NM
github.com/refraction-networking/utls v0.0.0-20210713165636-0b2885c8c0d4/go.mod h1:tz9gX959MEFfFN5whTIocCLUG57WiILqtdVxI8c6Wj0=
github.com/refraction-networking/utls v1.1.2 h1:a7GQauRt72VG+wtNm0lnrAaCGlyX47gEi1++dSsDBpw=
github.com/refraction-networking/utls v1.1.2/go.mod h1:+D89TUtA8+NKVFj1IXWr0p3tSdX1+SqUB7rL0QnGqyg=
github.com/refraction-networking/utls v1.1.3 h1:K9opY+iKxcGvHOBG2019wFEVtsNFh0f5WqHyc2i3iU0=
github.com/refraction-networking/utls v1.1.3/go.mod h1:+D89TUtA8+NKVFj1IXWr0p3tSdX1+SqUB7rL0QnGqyg=
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/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
Expand Down
16 changes: 13 additions & 3 deletions tunnel/tls/client.go
Expand Up @@ -69,16 +69,26 @@ func NewClient(ctx context.Context, underlay tunnel.Client) (*Client, error) {
cfg := config.FromContext(ctx, Name).(*Config)

helloID := tls.ClientHelloID{}
// keep the parameter name consistent with upstream
// https://github.com/refraction-networking/utls/blob/35e5b05fc4b6f8c4351d755f2570bc293f30aaf6/u_common.go#L114-L132
if cfg.TLS.Fingerprint != "" {
switch strings.ToLower(cfg.TLS.Fingerprint) {
case "firefox":
helloID = tls.HelloFirefox_Auto
case "chrome":
helloID = tls.HelloChrome_Auto
case "ios":
helloID = tls.HelloIOS_Auto
case "firefox":
helloID = tls.HelloFirefox_Auto
case "edge":
helloID = tls.HelloEdge_Auto
case "safari":
helloID = tls.HelloSafari_Auto
case "360browser":
helloID = tls.Hello360_Auto
case "qqbrowser":
helloID = tls.HelloQQ_Auto
default:
return nil, common.NewError("Invalid 'fingerprint' value in configuration: '" + cfg.TLS.Fingerprint + "'. Possible values are 'firefox', 'ios', or 'chrome' (default).")
return nil, common.NewError("Invalid 'fingerprint' value in configuration: '" + cfg.TLS.Fingerprint + "'. Possible values are 'chrome' (default), 'ios', 'firefox', 'edge', 'safari', '360browser', or 'qqbrowser'.")
}
log.Info("Your trojan's TLS fingerprint will look like", cfg.TLS.Fingerprint)
} else {
Expand Down

0 comments on commit d135694

Please sign in to comment.