Documentation
¶
Index ¶
- Variables
- func IsConnectionError(err error) bool
- func IsDNSError(err error) bool
- func IsProxyError(err error) bool
- func IsTLSError(err error) bool
- func IsTimeout(err error) bool
- func WrapError(op, host, port, protocol string, cause error) error
- type ConnStats
- type HTTP1ConnStats
- type HTTP1Transport
- type HTTP2Transport
- func (t *HTTP2Transport) Close()
- 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) Stats() map[string]ConnStats
- type HTTP3Stats
- type HTTP3Transport
- func (t *HTTP3Transport) Close() 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) Stats() HTTP3Stats
- type HTTPError
- type Protocol
- type ProxyConfig
- 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) 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 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 IsProxyError ¶
IsProxyError checks if an error is a proxy error
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 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) 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 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) 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) 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 (*HTTP3Transport) Close ¶
func (t *HTTP3Transport) Close() error
Close shuts down the transport and all connections
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) 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 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"
}
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 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) 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 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