Home >Backend Development >Golang >How to Establish UTLS Connections Through Proxies with HTTP 1.1 Requests?
Connecting via Proxy while Using UTLS and HTTP 1.1 Request
Establishing connections through proxies while using UTLS and HTTP 1.1 requests requires specific configuration.
Problem:
How can we utilize an HTTP or SOCKS5 proxy while opening a UTLS connection for randomized TLS fingerprinting?
Answer:
To utilize a proxy for UTLS connections, follow these steps:
Here's an example of a custom dialTLS function that accommodates proxy connections:
package main import ( "crypto/tls" "net" "net/url" "github.com/magisterquis/connectproxy" "golang.org/x/net/proxy" utls "github.com/refraction-networking/utls" ) var proxyString = "http://127.0.0.1:8080" dialTLS := func(network, addr string, _ *tls.Config) (net.Conn, error) { proxyURI, _ := url.Parse(proxyString) switch proxyURI.Scheme { case "socks5": proxyDialer, err = proxy.SOCKS5("tcp", proxyString, nil, proxy.Direct) case "http": proxyDialer, err = connectproxy.New(proxyURI, proxy.Direct) } conn, err := proxyDialer.Dial("tcp", addr) uconn := utls.UClient(conn, cfg, &utls.HelloRandomizedALPN) ... }
Additional Suggestions:
The above is the detailed content of How to Establish UTLS Connections Through Proxies with HTTP 1.1 Requests?. For more information, please follow other related articles on the PHP Chinese website!