mirror of
https://github.com/Snawoot/hola-proxy.git
synced 2026-04-02 18:28:12 +00:00
Merge pull request #153 from Snawoot/api_hide_SNI
Hide SNI for API calls as well
This commit is contained in:
24
holaapi.go
24
holaapi.go
@@ -398,6 +398,12 @@ func UpdateHolaTLSConfig(config *tls.Config) {
|
||||
tlsConfig = config
|
||||
}
|
||||
|
||||
var hideSNI bool
|
||||
|
||||
func SetHideSNI(hide bool) {
|
||||
hideSNI = hide
|
||||
}
|
||||
|
||||
// Returns default http client with a proxy override
|
||||
func httpClientWithProxy(agent *FallbackAgent) *http.Client {
|
||||
t := &http.Transport{
|
||||
@@ -428,7 +434,23 @@ func httpClientWithProxy(agent *FallbackAgent) *http.Client {
|
||||
if tlsConfig != nil {
|
||||
cfg = *tlsConfig
|
||||
}
|
||||
cfg.ServerName = host
|
||||
if !hideSNI {
|
||||
cfg.ServerName = host
|
||||
} else {
|
||||
cfg.InsecureSkipVerify = true
|
||||
cfg.VerifyConnection = func(cs tls.ConnectionState) error {
|
||||
opts := x509.VerifyOptions{
|
||||
DNSName: host,
|
||||
Intermediates: x509.NewCertPool(),
|
||||
Roots: cfg.RootCAs,
|
||||
}
|
||||
for _, cert := range cs.PeerCertificates[1:] {
|
||||
opts.Intermediates.AddCert(cert)
|
||||
}
|
||||
_, err := cs.PeerCertificates[0].Verify(opts)
|
||||
return err
|
||||
}
|
||||
}
|
||||
tlsConn := tls.UClient(conn, &cfg, tls.HelloAndroid_11_OkHttp)
|
||||
if err := tlsConn.HandshakeContext(ctx); err != nil {
|
||||
conn.Close()
|
||||
|
||||
Reference in New Issue
Block a user