Documentation
¶
Overview ¶
Package impersonate provides an http.Client whose TLS handshake is byte-identical to a real browser's, so requests survive JA3/JA4 fingerprinting (Cloudflare, Akamai, etc.) without a headless browser.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Chrome = chrome() ChromeAndroid = chromeAndroid() Firefox = firefox() Safari = safari() Edge = edge() IOS = ios() )
Built-in browser profiles (latest stable at release time).
var Profiles = map[string]Profile{ "chrome": Chrome, "chrome_android": ChromeAndroid, "firefox": Firefox, "safari": Safari, "edge": Edge, "ios": IOS, }
Profiles maps names to profiles for lookup by string.
Functions ¶
func NewTransport ¶
func NewTransport(p Profile, opts ...Option) http.RoundTripper
NewTransport returns a RoundTripper with the profile's TLS + headers.
Types ¶
type DialFunc ¶ added in v0.4.0
DialFunc establishes the raw TCP connection the browser TLS handshake runs over. Override it (e.g. with WithProxy) to route through a proxy.
func ProxyDialer ¶ added in v0.4.0
ProxyDialer returns a DialFunc that tunnels TCP connections through the proxy at rawurl. Supported schemes: socks5, socks5h, http, https.
type Option ¶ added in v0.4.0
type Option func(*config)
Option customizes a Client or Transport.
func WithDialer ¶ added in v0.4.0
WithDialer routes the underlying TCP connection through dial.
func WithProxy ¶ added in v0.4.0
WithProxy routes connections through a socks5:// or http(s):// proxy. An unparseable URL surfaces as an error on the first request rather than a panic; use ProxyDialer directly if you want the error up front.
func WithTimeout ¶ added in v0.4.0
WithTimeout sets the client timeout. It affects New; NewTransport ignores it.
type Profile ¶
type Profile struct {
Name string
ClientHello utls.ClientHelloID
Headers http.Header
HeaderOrder []string
H2Settings []http2.Setting
H2ConnWindow uint32
H2PseudoOrder []string
}
func (Profile) DialTLSContext ¶ added in v0.3.0
DialTLSContext dials addr and performs the profile's browser-exact TLS handshake (JA3/JA4 identical to the browser), returning the established connection. Plug it into a WebSocket client to get browser-fingerprinted wss:// connections:
// coder/websocket:
websocket.Dial(ctx, "wss://host/path", &websocket.DialOptions{
HTTPClient: &http.Client{Transport: impersonate.NewTransport(impersonate.Chrome)},
})
// gorilla/websocket:
d := websocket.Dialer{NetDialTLSContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
return impersonate.Chrome.DialTLSContext(ctx, network, addr)
}}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
measure
command
|
|
|
serve
command
Command serve exposes impersonate-http as an HTTP fetch API: POST a URL and a browser profile, get back the response fetched with that browser's exact TLS/HTTP2 fingerprint.
|
Command serve exposes impersonate-http as an HTTP fetch API: POST a URL and a browser profile, get back the response fetched with that browser's exact TLS/HTTP2 fingerprint. |