Documentation
¶
Index ¶
- Variables
- func IsConnectionError(err error) bool
- func IsDNSError(err error) bool
- func IsMASQUEProxy(proxyURL string) bool
- func IsProxyError(err error) bool
- func IsSOCKS5Proxy(proxyURL string) bool
- func IsTLSError(err error) bool
- func IsTimeout(err error) bool
- func SupportsQUIC(proxyURL string) bool
- func WrapError(op, host, port, protocol string, cause error) error
- type ConnStats
- type HTTP1ConnStats
- type HTTP1Transport
- func NewHTTP1Transport(preset *fingerprint.Preset, dnsCache *dns.Cache) *HTTP1Transport
- func NewHTTP1TransportWithConfig(preset *fingerprint.Preset, dnsCache *dns.Cache, proxy *ProxyConfig, ...) *HTTP1Transport
- func NewHTTP1TransportWithProxy(preset *fingerprint.Preset, dnsCache *dns.Cache, proxy *ProxyConfig) *HTTP1Transport
- func (t *HTTP1Transport) Close()
- func (t *HTTP1Transport) GetDNSCache() *dns.Cache
- func (t *HTTP1Transport) RoundTrip(req *http.Request) (*http.Response, error)
- func (t *HTTP1Transport) SetConnectTo(requestHost, connectHost string)
- func (t *HTTP1Transport) SetInsecureSkipVerify(skip bool)
- func (t *HTTP1Transport) Stats() map[string]HTTP1ConnStats
- type HTTP2Transport
- func NewHTTP2Transport(preset *fingerprint.Preset, dnsCache *dns.Cache) *HTTP2Transport
- func NewHTTP2TransportWithConfig(preset *fingerprint.Preset, dnsCache *dns.Cache, proxy *ProxyConfig, ...) *HTTP2Transport
- func NewHTTP2TransportWithProxy(preset *fingerprint.Preset, dnsCache *dns.Cache, proxy *ProxyConfig) *HTTP2Transport
- func (t *HTTP2Transport) Close()
- func (t *HTTP2Transport) Connect(ctx context.Context, host, port string) error
- func (t *HTTP2Transport) GetConnectionUseCount(host, port string) int64
- func (t *HTTP2Transport) GetDNSCache() *dns.Cache
- func (t *HTTP2Transport) IsConnectionReused(host, port string) bool
- func (t *HTTP2Transport) RoundTrip(req *http.Request) (*http.Response, error)
- func (t *HTTP2Transport) SetConnectTo(requestHost, connectHost string)
- func (t *HTTP2Transport) Stats() map[string]ConnStats
- type HTTP3Stats
- type HTTP3Transport
- func NewHTTP3Transport(preset *fingerprint.Preset, dnsCache *dns.Cache) *HTTP3Transport
- func NewHTTP3TransportWithConfig(preset *fingerprint.Preset, dnsCache *dns.Cache, proxyConfig *ProxyConfig, ...) (*HTTP3Transport, error)
- func NewHTTP3TransportWithMASQUE(preset *fingerprint.Preset, dnsCache *dns.Cache, proxyConfig *ProxyConfig, ...) (*HTTP3Transport, error)
- func NewHTTP3TransportWithProxy(preset *fingerprint.Preset, dnsCache *dns.Cache, proxyConfig *ProxyConfig) (*HTTP3Transport, error)
- func NewHTTP3TransportWithTransportConfig(preset *fingerprint.Preset, dnsCache *dns.Cache, config *TransportConfig) *HTTP3Transport
- func (t *HTTP3Transport) Close() error
- func (t *HTTP3Transport) Connect(ctx context.Context, host, port string) error
- func (t *HTTP3Transport) GetDNSCache() *dns.Cache
- func (t *HTTP3Transport) GetDialCount() int64
- func (t *HTTP3Transport) GetRequestCount() int64
- func (t *HTTP3Transport) IsConnectionReused(host string) bool
- func (t *HTTP3Transport) RoundTrip(req *http.Request) (*http.Response, error)
- func (t *HTTP3Transport) SetConnectTo(requestHost, connectHost string)
- func (t *HTTP3Transport) SetECHConfig(echConfig []byte)
- func (t *HTTP3Transport) SetECHConfigDomain(domain string)
- func (t *HTTP3Transport) Stats() HTTP3Stats
- type HTTPError
- type Protocol
- type ProxyConfig
- type RedirectInfo
- type Request
- type Response
- type Transport
- func (t *Transport) ClearProtocolCache()
- func (t *Transport) Close()
- func (t *Transport) Do(ctx context.Context, req *Request) (*Response, error)
- func (t *Transport) GetDNSCache() *dns.Cache
- func (t *Transport) SetConnectTo(requestHost, connectHost string)
- func (t *Transport) SetECHConfig(echConfig []byte)
- func (t *Transport) SetECHConfigDomain(domain string)
- func (t *Transport) SetInsecureSkipVerify(skip bool)
- func (t *Transport) SetPreset(presetName string)
- func (t *Transport) SetProtocol(p Protocol)
- func (t *Transport) SetProxy(proxy *ProxyConfig)
- func (t *Transport) SetTimeout(timeout time.Duration)
- func (t *Transport) Stats() map[string]interface{}
- type TransportConfig
- type TransportError
- func NewConnectionError(op, host, port, protocol string, cause error) *TransportError
- func NewDNSError(host string, cause error) *TransportError
- func NewProtocolError(host, port, protocol string, cause error) *TransportError
- func NewProxyError(op, host, port string, cause error) *TransportError
- func NewRequestError(op, host, port, protocol string, cause error) *TransportError
- func NewTLSError(op, host, port, protocol string, cause error) *TransportError
- func NewTimeoutError(op, host, port, protocol string, cause error) *TransportError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConnection represents connection-level errors ErrConnection = errors.New("connection error") // ErrTLS represents TLS/SSL related errors ErrTLS = errors.New("TLS error") // ErrDNS represents DNS resolution errors ErrDNS = errors.New("DNS error") // ErrTimeout represents timeout errors ErrTimeout = errors.New("timeout error") // ErrProxy represents proxy-related errors ErrProxy = errors.New("proxy error") // ErrProtocol represents protocol negotiation errors ErrProtocol = errors.New("protocol error") // ErrRequest represents request-level errors ErrRequest = errors.New("request error") // ErrResponse represents response-level errors ErrResponse = errors.New("response error") // ErrClosed represents errors when transport is closed ErrClosed = errors.New("transport closed") )
Error categories for better error handling
Functions ¶
func IsConnectionError ¶
IsConnectionError checks if an error is a connection error
func IsMASQUEProxy ¶ added in v1.5.2
IsMASQUEProxy checks if the proxy URL should use MASQUE protocol (exported version). Returns true for masque:// scheme or known MASQUE providers with https://
func IsProxyError ¶
IsProxyError checks if an error is a proxy error
func IsSOCKS5Proxy ¶ added in v1.5.2
IsSOCKS5Proxy checks if the proxy URL is a SOCKS5 proxy (exported version)
func SupportsQUIC ¶ added in v1.5.2
SupportsQUIC checks if the proxy URL supports QUIC/HTTP3 tunneling. Returns true for SOCKS5 (UDP relay) or MASQUE (CONNECT-UDP) proxies.
Types ¶
type ConnStats ¶
type ConnStats struct {
Host string
CreatedAt time.Time
LastUsedAt time.Time
UseCount int64
Age time.Duration
IdleTime time.Duration
IsReused bool
SessionResumed bool // True if TLS session was resumed
TLSVersion uint16 // TLS version (e.g., 0x0304 for TLS 1.3)
CipherSuite uint16 // Negotiated cipher suite
}
ConnStats contains connection statistics
type HTTP1ConnStats ¶
type HTTP1ConnStats struct {
IdleConns int
TotalUseCount int64
OldestCreated time.Time
NewestLastUsed time.Time
}
HTTP1ConnStats contains HTTP/1.1 connection statistics
type HTTP1Transport ¶
type HTTP1Transport struct {
// contains filtered or unexported fields
}
HTTP1Transport is a custom HTTP/1.1 transport with uTLS fingerprinting and connection pooling with keep-alive support
func NewHTTP1Transport ¶
func NewHTTP1Transport(preset *fingerprint.Preset, dnsCache *dns.Cache) *HTTP1Transport
NewHTTP1Transport creates a new HTTP/1.1 transport with uTLS
func NewHTTP1TransportWithConfig ¶ added in v1.5.2
func NewHTTP1TransportWithConfig(preset *fingerprint.Preset, dnsCache *dns.Cache, proxy *ProxyConfig, config *TransportConfig) *HTTP1Transport
NewHTTP1TransportWithConfig creates a new HTTP/1.1 transport with proxy and config
func NewHTTP1TransportWithProxy ¶
func NewHTTP1TransportWithProxy(preset *fingerprint.Preset, dnsCache *dns.Cache, proxy *ProxyConfig) *HTTP1Transport
NewHTTP1TransportWithProxy creates a new HTTP/1.1 transport with optional proxy
func (*HTTP1Transport) GetDNSCache ¶
func (t *HTTP1Transport) GetDNSCache() *dns.Cache
GetDNSCache returns the DNS cache
func (*HTTP1Transport) SetConnectTo ¶ added in v1.5.2
func (t *HTTP1Transport) SetConnectTo(requestHost, connectHost string)
SetConnectTo sets a host mapping for domain fronting (stub for HTTP/1.1)
func (*HTTP1Transport) SetInsecureSkipVerify ¶
func (t *HTTP1Transport) SetInsecureSkipVerify(skip bool)
SetInsecureSkipVerify sets whether to skip TLS verification
func (*HTTP1Transport) Stats ¶
func (t *HTTP1Transport) Stats() map[string]HTTP1ConnStats
Stats returns transport statistics
type HTTP2Transport ¶
type HTTP2Transport struct {
// contains filtered or unexported fields
}
HTTP2Transport is a custom HTTP/2 transport with uTLS fingerprinting and proper connection reuse
func NewHTTP2Transport ¶
func NewHTTP2Transport(preset *fingerprint.Preset, dnsCache *dns.Cache) *HTTP2Transport
NewHTTP2Transport creates a new HTTP/2 transport with uTLS
func NewHTTP2TransportWithConfig ¶ added in v1.5.2
func NewHTTP2TransportWithConfig(preset *fingerprint.Preset, dnsCache *dns.Cache, proxy *ProxyConfig, config *TransportConfig) *HTTP2Transport
NewHTTP2TransportWithConfig creates a new HTTP/2 transport with proxy and advanced config
func NewHTTP2TransportWithProxy ¶
func NewHTTP2TransportWithProxy(preset *fingerprint.Preset, dnsCache *dns.Cache, proxy *ProxyConfig) *HTTP2Transport
NewHTTP2TransportWithProxy creates a new HTTP/2 transport with optional proxy support
func (*HTTP2Transport) Connect ¶ added in v1.0.11
func (t *HTTP2Transport) Connect(ctx context.Context, host, port string) error
Connect establishes a connection to the host without making a request. This is used for protocol racing - the first protocol to connect wins.
func (*HTTP2Transport) GetConnectionUseCount ¶
func (t *HTTP2Transport) GetConnectionUseCount(host, port string) int64
GetConnectionUseCount returns how many times a connection has been used
func (*HTTP2Transport) GetDNSCache ¶
func (t *HTTP2Transport) GetDNSCache() *dns.Cache
GetDNSCache returns the DNS cache
func (*HTTP2Transport) IsConnectionReused ¶
func (t *HTTP2Transport) IsConnectionReused(host, port string) bool
IsConnectionReused checks if the connection for a host will be reused Returns true if a usable connection already exists in the pool
func (*HTTP2Transport) SetConnectTo ¶ added in v1.5.2
func (t *HTTP2Transport) SetConnectTo(requestHost, connectHost string)
SetConnectTo sets a host mapping for domain fronting
func (*HTTP2Transport) Stats ¶
func (t *HTTP2Transport) Stats() map[string]ConnStats
Stats returns transport statistics
type HTTP3Stats ¶
type HTTP3Stats struct {
RequestCount int64
DialCount int64 // Number of new connections created
Reusing bool // True if connections are being reused
}
HTTP3Stats contains HTTP/3 transport statistics
type HTTP3Transport ¶
type HTTP3Transport struct {
// contains filtered or unexported fields
}
HTTP3Transport is an HTTP/3 transport with proper QUIC connection reuse http3.Transport handles connection pooling internally - we just provide DNS resolution
func NewHTTP3Transport ¶
func NewHTTP3Transport(preset *fingerprint.Preset, dnsCache *dns.Cache) *HTTP3Transport
NewHTTP3Transport creates a new HTTP/3 transport
func NewHTTP3TransportWithConfig ¶ added in v1.5.2
func NewHTTP3TransportWithConfig(preset *fingerprint.Preset, dnsCache *dns.Cache, proxyConfig *ProxyConfig, config *TransportConfig) (*HTTP3Transport, error)
NewHTTP3TransportWithConfig creates a new HTTP/3 transport with SOCKS5 proxy and advanced config
func NewHTTP3TransportWithMASQUE ¶ added in v1.5.2
func NewHTTP3TransportWithMASQUE(preset *fingerprint.Preset, dnsCache *dns.Cache, proxyConfig *ProxyConfig, config *TransportConfig) (*HTTP3Transport, error)
NewHTTP3TransportWithMASQUE creates a new HTTP/3 transport with MASQUE proxy support. MASQUE allows HTTP/3 (QUIC) traffic to be tunneled through an HTTP/3 proxy using the CONNECT-UDP method defined in RFC 9298.
func NewHTTP3TransportWithProxy ¶ added in v1.5.2
func NewHTTP3TransportWithProxy(preset *fingerprint.Preset, dnsCache *dns.Cache, proxyConfig *ProxyConfig) (*HTTP3Transport, error)
NewHTTP3TransportWithProxy creates a new HTTP/3 transport with SOCKS5 proxy support Only SOCKS5 proxies support UDP relay needed for QUIC/HTTP3
func NewHTTP3TransportWithTransportConfig ¶ added in v1.5.2
func NewHTTP3TransportWithTransportConfig(preset *fingerprint.Preset, dnsCache *dns.Cache, config *TransportConfig) *HTTP3Transport
NewHTTP3TransportWithTransportConfig creates a new HTTP/3 transport with advanced config
func (*HTTP3Transport) Close ¶
func (t *HTTP3Transport) Close() error
Close shuts down the transport and all connections
func (*HTTP3Transport) Connect ¶ added in v1.0.11
func (t *HTTP3Transport) Connect(ctx context.Context, host, port string) error
Connect establishes a QUIC connection to the host without making a request. This is used for protocol racing - the first protocol to connect wins.
func (*HTTP3Transport) GetDNSCache ¶
func (t *HTTP3Transport) GetDNSCache() *dns.Cache
GetDNSCache returns the DNS cache
func (*HTTP3Transport) GetDialCount ¶
func (t *HTTP3Transport) GetDialCount() int64
GetDialCount returns the number of new connections created
func (*HTTP3Transport) GetRequestCount ¶
func (t *HTTP3Transport) GetRequestCount() int64
GetRequestCount returns the total number of requests made
func (*HTTP3Transport) IsConnectionReused ¶
func (t *HTTP3Transport) IsConnectionReused(host string) bool
IsConnectionReused returns true if requests > dials (meaning reuse happened)
func (*HTTP3Transport) SetConnectTo ¶ added in v1.5.2
func (t *HTTP3Transport) SetConnectTo(requestHost, connectHost string)
SetConnectTo sets a host mapping for domain fronting
func (*HTTP3Transport) SetECHConfig ¶ added in v1.5.2
func (t *HTTP3Transport) SetECHConfig(echConfig []byte)
SetECHConfig sets a custom ECH configuration
func (*HTTP3Transport) SetECHConfigDomain ¶ added in v1.5.2
func (t *HTTP3Transport) SetECHConfigDomain(domain string)
SetECHConfigDomain sets a domain to fetch ECH config from
func (*HTTP3Transport) Stats ¶
func (t *HTTP3Transport) Stats() HTTP3Stats
Stats returns transport statistics
type HTTPError ¶
HTTPError represents an HTTP-level error (4xx, 5xx responses)
func NewHTTPError ¶
NewHTTPError creates an HTTP error from status code
func (*HTTPError) IsClientError ¶
IsClientError returns true for 4xx errors
func (*HTTPError) IsRetryable ¶
IsRetryable returns true for errors that should be retried
func (*HTTPError) IsServerError ¶
IsServerError returns true for 5xx errors
type ProxyConfig ¶
type ProxyConfig struct {
URL string // Proxy URL (e.g., "http://proxy:8080" or "http://user:pass@proxy:8080")
Username string // Proxy username (optional, can also be in URL)
Password string // Proxy password (optional, can also be in URL)
}
ProxyConfig contains proxy server configuration
type RedirectInfo ¶ added in v1.5.1
RedirectInfo contains information about a redirect response
type Request ¶
type Request struct {
Method string
URL string
Headers map[string]string
Body []byte
Timeout time.Duration
}
Request represents an HTTP request
type Response ¶
type Response struct {
StatusCode int
Headers map[string]string
Body []byte
FinalURL string
Timing *protocol.Timing
Protocol string // "h1", "h2", or "h3"
History []*RedirectInfo
}
Response represents an HTTP response
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is a unified HTTP transport supporting HTTP/1.1, HTTP/2, and HTTP/3
func NewTransport ¶
NewTransport creates a new unified transport
func NewTransportWithConfig ¶ added in v1.5.2
func NewTransportWithConfig(presetName string, proxy *ProxyConfig, config *TransportConfig) *Transport
NewTransportWithConfig creates a new unified transport with proxy and config
func NewTransportWithProxy ¶
func NewTransportWithProxy(presetName string, proxy *ProxyConfig) *Transport
NewTransportWithProxy creates a new unified transport with optional proxy
func (*Transport) ClearProtocolCache ¶
func (t *Transport) ClearProtocolCache()
ClearProtocolCache clears the learned protocol support cache
func (*Transport) GetDNSCache ¶
GetDNSCache returns the DNS cache
func (*Transport) SetConnectTo ¶ added in v1.5.2
SetConnectTo sets a host mapping for domain fronting
func (*Transport) SetECHConfig ¶ added in v1.5.2
SetECHConfig sets a custom ECH configuration
func (*Transport) SetECHConfigDomain ¶ added in v1.5.2
SetECHConfigDomain sets a domain to fetch ECH config from
func (*Transport) SetInsecureSkipVerify ¶
SetInsecureSkipVerify sets whether to skip TLS certificate verification
func (*Transport) SetProtocol ¶
SetProtocol sets the preferred protocol
func (*Transport) SetProxy ¶
func (t *Transport) SetProxy(proxy *ProxyConfig)
SetProxy sets or updates the proxy configuration Note: This recreates the underlying transports
func (*Transport) SetTimeout ¶
SetTimeout sets the request timeout
type TransportConfig ¶ added in v1.5.2
type TransportConfig struct {
// ConnectTo maps request hosts to connection hosts (domain fronting).
// Key: request host, Value: connection host for DNS resolution
ConnectTo map[string]string
// ECHConfig is a custom ECH configuration (overrides DNS fetch)
ECHConfig []byte
// ECHConfigDomain is a domain to fetch ECH config from instead of target
ECHConfigDomain string
}
TransportConfig contains advanced transport configuration
func (*TransportConfig) GetConnectHost ¶ added in v1.5.2
func (c *TransportConfig) GetConnectHost(requestHost string) string
GetConnectHost returns the connection host for a request host. If there's a ConnectTo mapping, returns the mapped host. Otherwise returns the original host.
func (*TransportConfig) GetECHConfig ¶ added in v1.5.2
func (c *TransportConfig) GetECHConfig(ctx context.Context, targetHost string) []byte
GetECHConfig returns the ECH config to use for a host. Returns custom config if set, otherwise fetches from ECHConfigDomain or target host.
type TransportError ¶
type TransportError struct {
Op string // Operation that failed (e.g., "dial", "tls_handshake", "request")
Host string // Target host
Port string // Target port
Protocol string // Protocol (h1, h2, h3)
Cause error // Underlying error
Category error // Error category (ErrConnection, ErrTLS, etc.)
Retryable bool // Whether the operation can be retried
}
TransportError provides detailed error information
func NewConnectionError ¶
func NewConnectionError(op, host, port, protocol string, cause error) *TransportError
NewConnectionError creates a connection error
func NewDNSError ¶
func NewDNSError(host string, cause error) *TransportError
NewDNSError creates a DNS error
func NewProtocolError ¶
func NewProtocolError(host, port, protocol string, cause error) *TransportError
NewProtocolError creates a protocol negotiation error
func NewProxyError ¶
func NewProxyError(op, host, port string, cause error) *TransportError
NewProxyError creates a proxy error
func NewRequestError ¶
func NewRequestError(op, host, port, protocol string, cause error) *TransportError
NewRequestError creates a request error
func NewTLSError ¶
func NewTLSError(op, host, port, protocol string, cause error) *TransportError
NewTLSError creates a TLS error
func NewTimeoutError ¶
func NewTimeoutError(op, host, port, protocol string, cause error) *TransportError
NewTimeoutError creates a timeout error
func (*TransportError) Error ¶
func (e *TransportError) Error() string
Error implements the error interface
func (*TransportError) Is ¶
func (e *TransportError) Is(target error) bool
Is checks if the error matches the target
func (*TransportError) IsRetryable ¶
func (e *TransportError) IsRetryable() bool
IsRetryable returns whether the error is retryable
func (*TransportError) Unwrap ¶
func (e *TransportError) Unwrap() error
Unwrap returns the underlying error