fingerprint

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fingerprint implements browser transport fingerprinting (TLS ClientHello + HTTP/2 frames + ordered, case-exact header block) as a standard net/http RoundTripper, so the httpc engine (redirects, retries, middleware, streaming) stays authoritative.

The transport is github.com/bogdanfinn/tls-client (BSD-3): it owns the uTLS handshake, the HTTP/2 frame layer and the HTTP/1.1 writer that preserves header casing. What this package keeps is everything the fingerprint data and the httpc contract depend on — the browser profiles and their ClientHello specs, the per-method header pipeline, redirect-hop coherence, proxy-pool integration, SSRF pre-flight, response decoding, and the certificate-pinning adapter. httpc depends on none of enetx/http, enetx/http2 or refraction-networking/utls for this path any more.

Design notes:

  • One backend (one tls-client instance) per proxy selection is cached; the httpc proxy pool (rotation, circuit breaking, ProxyRecorder attribution) continues to govern selection via PoolManager.SelectProxy. Proxies are baked in at construction and never swapped at runtime: tls-client's SetProxy rebuilds its transport in place without a lock, which races with in-flight requests, so rotation happens by picking a different cached backend instead.
  • Redirects are NOT followed by the backend: the adapter is a plain http.RoundTripper, so the engine's http.Client CheckRedirect policy drives the chain. Redirect hops stay browser-coherent (redirect.go): sec-fetch-site is recomputed against the previous hop's URL, sec-fetch-user is dropped after the first hop, and a 301/302/303 downgraded fetch chain keeps fetch-style header tables.
  • Protocol negotiation is the transport's own (ALPN over the profile's ClientHello). Connection.EnableHTTP2=false rewrites the ALPN list to http/1.1 and pins the stack to HTTP/1.1, mirroring the standard transport's protocol choice. HTTP/3 is deliberately never attempted: a QUIC connection uses a separate TLS stack that bypasses the certificate pinner, and it would also break the single-fingerprint invariant across a connection's lifetime.
  • The browser profile's header set is authoritative: the per-request pipeline replaces same-named request headers (User-Agent, Accept, Accept-Language, ...) so the wire stays coherent with the spoofed ClientHello. Custom headers pass through untouched.
  • Certificate pinning IS supported on this path: the public CertificatePinner runs as the transport's Pin hook on every fingerprinted handshake (under InsecureSkipVerify it becomes the only gate, pinning the leaf — the same trust model as the pooled transport path).
  • Response bodies arrive decoded (gzip/deflate/br/zstd, see decode.go); the engine sees identity bodies with Content-Length already reset. The transport's own decompression is switched off so decoding happens once.
  • SSRF protection uses a pre-flight resolve+validate (the backend dials on its own, so the connection-layer validator cannot apply). Two gaps remain versus the standard path, documented in the public SecurityConfig.TLSFingerprint docs: (a) a theoretical TOCTOU window between validation and the backend's own DNS resolution, and (b) a host that resolves to a MIX of public and private addresses passes the "at least one allowed IP" pre-flight, and the backend's second resolution may land on the private record — deterministically, with no DNS rebinding required (the standard path dials only validated IP literals and has neither gap).

Index

Constants

View Source
const (
	MLDSA44 = utls.MLDSA44
	MLDSA65 = utls.MLDSA65
	MLDSA87 = utls.MLDSA87
)

ML-DSA (post-quantum) TLS 1.3 signature schemes that Chrome 152 advertises at the head of its signature_algorithms list. uTLS names them (utls.MLDSA44 and friends), so the profile spells them through the library rather than raw code points; the constants are re-exported here for the profile data below and pinned by TestChromeSpec_SignatureAlgorithms.

View Source
const ChromeMajor = 155

ChromeMajor is the shipped Chrome major —the label the UA map and brand list claim. The drift gates compare it against the current stable major.

View Source
const FirefoxMajor = 158

FirefoxMajor is the shipped Firefox major —the label the UA map claims. The drift gates compare it against the current stable major.

Variables

This section is empty.

Functions

func ResolvePresetName

func ResolvePresetName(v string) (string, bool)

ResolvePresetName normalizes a configured fingerprint value (short alias, version-accurate name, or OS-suffixed name like "chrome", "chrome-152", "chrome-windows") and reports whether the registry knows it. Matching is case-insensitive with surrounding whitespace trimmed, mirroring the tolerance the previous backend's resolver had for "Chrome" / " chrome ".

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter implements http.RoundTripper over the fingerprinted backend.

func NewAdapter

func NewAdapter(cfg Config) *Adapter

NewAdapter constructs the adapter. The preset must already be validated (ResolvePresetName ok); an invalid name fails the base build and the error surfaces on first use — the public config layer is the gate.

func (*Adapter) Close

func (a *Adapter) Close() error

Close closes idle connections on every backend (base and per-proxy) and drops the per-proxy backends; the adapter itself remains usable — per-proxy backends are rebuilt lazily on the next proxied request, and the base backend keeps serving direct connections. Safe to call multiple times (subsequent calls are no-ops).

func (*Adapter) CloseIdleConnections

func (a *Adapter) CloseIdleConnections()

CloseIdleConnections closes every backend's idle connections (base and per-proxy) while keeping the backends themselves usable — the next request dials fresh. Satisfies http.RoundTripper's optional CloseIdleConnections contract, and lets callers force fresh connections (for example to exercise session resumption rather than idle reuse).

func (*Adapter) RoundTrip

func (a *Adapter) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes one HTTP round trip through the fingerprinted backend.

type Config

type Config struct {
	// PresetName is the resolved preset name (never empty when the adapter
	// is constructed; validated by the public config layer).
	PresetName string

	// InsecureSkipVerify mirrors Security.InsecureSkipVerify: verification
	// runs unless the user explicitly opted out (verify-by-default).
	InsecureSkipVerify bool

	// AllowPrivateIPs mirrors Security.AllowPrivateIPs: when false, the
	// pre-flight SSRF check runs for every request.
	AllowPrivateIPs bool

	// EnableHTTP2 mirrors Connection.EnableHTTP2. When false, the backend is
	// pinned to HTTP/1.1 (ALPN restricted) so the fingerprint path honors
	// the same protocol choice as the standard stack.
	EnableHTTP2 bool

	// ExemptNets mirrors Security.SSRFExemptCIDRs (pre-parsed).
	ExemptNets []*net.IPNet

	// DisableSessionTickets mirrors Security.TLSFingerprintDisableSessionTickets:
	// true forces a full TLS handshake on every connection by turning the
	// transport's session-ticket cache off. Without it the transport resumes
	// sessions on profiles whose ClientHello carries a pre_shared_key
	// extension (the Chrome profiles) — per backend, so proxy pools never
	// share ticket state — exactly like a real browser revisiting a host.
	DisableSessionTickets bool

	// CertPinner, when set, runs as the transport's certificate-pin hook on
	// every fingerprinted TLS handshake (nil disables pinning).
	CertPinner certPinner

	// Pool is the owning connection PoolManager (may be nil in tests); it
	// supplies proxy selection and circuit-breaker reporting.
	Pool *connection.PoolManager
}

Config wires the adapter to the owning engine client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL