Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedVersion = errors.New("unsupported version") ErrUnsupportedPlatform = errors.New("unsupported platform") )
Functions ¶
This section is empty.
Types ¶
type ClientSpec ¶
type ClientSpec struct {
// contains filtered or unexported fields
}
ClientSpec holds all browser-specific configuration needed to mimic a browser's TLS, HTTP/2, and header fingerprints.
func Chromium ¶
func Chromium(brand Brand, version string) (*ClientSpec, error)
Chromium creates a ClientSpec that mimics a Chromium-based browser's TLS and HTTP/2 fingerprint. Supported brands are BrandChrome, BrandBrave, and BrandEdge. Version should be the full Chromium version string (e.g., "137.0.0.0"). Minimum supported version is 100.
func Firefox ¶
func Firefox(version string) (*ClientSpec, error)
Firefox creates a ClientSpec that mimics Firefox's TLS and HTTP/2 fingerprint. Version should be the Firefox version (e.g., "134.0", "120.0"). Minimum supported version is 55.
Firefox does not send sec-ch-ua client hint headers.
Note: Firefox sends standalone PRIORITY frames at connection start to build a dependency tree. This is not supported by the underlying HTTP/2 transport, so the Akamai PRIORITY section of the fingerprint will differ from real Firefox. The TLS, SETTINGS, WINDOW_UPDATE, and pseudo-header order are all matched.
func Safari ¶
func Safari(version string) (*ClientSpec, error)
Safari creates a ClientSpec that mimics Safari's TLS and HTTP/2 fingerprint. Version should be the Safari version (e.g., "18.3", "17.0", "16.0"). Minimum supported version is 16.
The TLS fingerprint is platform-dependent: macOS and iPadOS use the Safari desktop fingerprint, while iOS uses the iOS-specific fingerprint.
Safari does not send sec-ch-ua client hint headers.
func (*ClientSpec) ConfigureTransport ¶
func (c *ClientSpec) ConfigureTransport(t *http.Transport, platform Platform) error
ConfigureTransport configures an http.Transport with the client's TLS and HTTP/2 settings for the given platform. The transport is modified in-place.
func (*ClientSpec) HTTP2Opts ¶
func (c *ClientSpec) HTTP2Opts() *HTTP2Options
HTTP2Opts returns the HTTP/2 configuration for the mimicked client.
func (*ClientSpec) PseudoHeaderOrder ¶
func (c *ClientSpec) PseudoHeaderOrder() []string
PseudoHeaderOrder returns the HTTP/2 pseudo header order for the mimicked client.
func (*ClientSpec) Version ¶
func (c *ClientSpec) Version() string
Version returns the version string for the mimicked client.
type HTTP2Options ¶
type HTTP2Options struct {
// Settings are the HTTP/2 SETTINGS frame entries sent at connection start.
Settings []http2.Setting
// PseudoHeaderOrder is the order of HTTP/2 pseudo headers.
// Chrome uses m,a,s,p; Safari uses m,s,p,a; Firefox uses m,p,a,s.
PseudoHeaderOrder []string
// MaxHeaderListSize is the local limit on received header list size.
MaxHeaderListSize uint32
// InitialWindowSize is the stream-level initial flow control window size.
InitialWindowSize uint32
// HeaderTableSize is the HPACK decoder table size.
HeaderTableSize uint32
// ConnectionFlow is the WINDOW_UPDATE value sent on stream 0 at connection start.
// A value of 0 uses fhttp's default (15663105).
ConnectionFlow uint32
// HeaderPriority controls the priority parameters sent in HEADERS frames.
// A nil value uses fhttp's default (Exclusive=true, Weight=255).
HeaderPriority *http2.PriorityParam
}
HTTP2Options holds HTTP/2 configuration for a browser fingerprint.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements http.RoundTripper and handles:
- Setting default headers for the mimicked browser
- Setting the HTTP/2 pseudo-header order
- Randomizing header order to match real browser behavior
func NewTransport ¶
func NewTransport(spec *ClientSpec, platform Platform, opts ...TransportOption) (*Transport, error)
NewTransport creates a new Transport that mimics the given browser spec on the given platform. It configures TLS fingerprinting, HTTP/2 settings, and default headers to match the specified browser's real-world behavior.
Use Chromium(), Safari(), or Firefox() to create a ClientSpec.
type TransportOption ¶
type TransportOption func(*transportConfig)
TransportOption configures a Transport.
func WithBaseTransport ¶
func WithBaseTransport(t *http.Transport) TransportOption
WithBaseTransport sets the underlying HTTP transport. If not set, a default transport is created.