Documentation
¶
Index ¶
- type Body
- func (b *Body) Bytes() g.Bytes
- func (b *Body) Close() error
- func (b *Body) Contains(pattern any) bool
- func (b *Body) Dump(filename g.String) error
- func (b *Body) JSON(data any) error
- func (b *Body) Limit(limit int64) *Body
- func (b *Body) MD5() g.String
- func (b *Body) SSE(fn func(event *sse.Event) bool) error
- func (b *Body) Stream() *bufio.Reader
- func (b *Body) String() g.String
- func (b *Body) UTF8() g.String
- func (b *Body) XML(data any) error
- type Builder
- func (b *Builder) AddCookies(cookies ...*http.Cookie) *Builder
- func (b *Builder) AddHeaders(headers ...any) *Builder
- func (b *Builder) BasicAuth(authentication g.String) *Builder
- func (b *Builder) BearerAuth(authentication g.String) *Builder
- func (b *Builder) Boundary(boundary func() g.String) *Builder
- func (b *Builder) Build() *Client
- func (b *Builder) CacheBody() *Builder
- func (b *Builder) ContentType(contentType g.String) *Builder
- func (b *Builder) DNS(dns g.String) *Builder
- func (b *Builder) DNSOverTLS() *DNSOverTLS
- func (b *Builder) DisableCompression() *Builder
- func (b *Builder) DisableKeepAlive() *Builder
- func (b *Builder) FollowOnlyHostRedirects() *Builder
- func (b *Builder) ForceHTTP1() *Builder
- func (b *Builder) ForwardHeadersOnRedirect() *Builder
- func (b *Builder) GetRemoteAddress() *Builder
- func (b *Builder) H2C() *Builder
- func (b *Builder) HTTP2Settings() *HTTP2Settings
- func (b *Builder) HTTP3() *Builder
- func (b *Builder) HTTP3Settings() *HTTP3Settings
- func (b *Builder) Impersonate() *Impersonate
- func (b *Builder) InterfaceAddr(address g.String) *Builder
- func (b *Builder) JA() *JA
- func (b *Builder) MaxRedirects(maxRedirects int) *Builder
- func (b *Builder) NotFollowRedirects() *Builder
- func (b *Builder) Proxy(proxy any) *Builder
- func (b *Builder) RedirectPolicy(fn func(*http.Request, []*http.Request) error) *Builder
- func (b *Builder) Retry(retryMax int, retryWait time.Duration, codes ...int) *Builder
- func (b *Builder) Session() *Builder
- func (b *Builder) SetHeaders(headers ...any) *Builder
- func (b *Builder) Singleton() *Builder
- func (b Builder) String() string
- func (b *Builder) Timeout(timeout time.Duration) *Builder
- func (b *Builder) UnixDomainSocket(socketPath g.String) *Builder
- func (b *Builder) UserAgent(userAgent any) *Builder
- func (b *Builder) With(middleware any, priority ...int) *Builder
- func (b *Builder) WithContext(ctx context.Context) *Builder
- type Client
- func (c *Client) Builder() *Builder
- func (c *Client) CloseIdleConnections()
- func (c *Client) Delete(rawURL g.String, data ...any) *Request
- func (c *Client) FileUpload(rawURL, fieldName, filePath g.String, data ...any) *Request
- func (c *Client) Get(rawURL g.String, data ...any) *Request
- func (c *Client) GetClient() *http.Client
- func (c *Client) GetDialer() *net.Dialer
- func (c *Client) GetTLSConfig() *tls.Config
- func (c *Client) GetTransport() http.RoundTripper
- func (c *Client) Head(rawURL g.String) *Request
- func (c *Client) IsHTTP3() bool
- func (c *Client) Multipart(rawURL g.String, multipartData g.MapOrd[g.String, g.String]) *Request
- func (c *Client) Patch(rawURL g.String, data any) *Request
- func (c *Client) Post(rawURL g.String, data any) *Request
- func (c *Client) Put(rawURL g.String, data any) *Request
- func (c *Client) Raw(raw, scheme g.String) *Request
- func (c *Client) Std() *_http.Client
- type CookieJarAdapter
- type Cookies
- type DNSOverTLS
- func (dot *DNSOverTLS) AdGuard() *Builder
- func (dot *DNSOverTLS) AddProvider(serverName g.String, addresses ...g.String) *Builder
- func (dot *DNSOverTLS) Ali() *Builder
- func (dot *DNSOverTLS) CIRAShield() *Builder
- func (dot *DNSOverTLS) Cloudflare() *Builder
- func (dot *DNSOverTLS) Forge() *Builder
- func (dot *DNSOverTLS) Google() *Builder
- func (dot *DNSOverTLS) LibreDNS() *Builder
- func (dot *DNSOverTLS) Quad9() *Builder
- func (dot *DNSOverTLS) Quad101() *Builder
- func (dot *DNSOverTLS) SB() *Builder
- func (dot *DNSOverTLS) Switch() *Builder
- type Debug
- type Err101ResponseCode
- type ErrUserAgentType
- type ErrWebSocketUpgrade
- type HTTP2Settings
- func (h *HTTP2Settings) ConnectionFlow(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) EnablePush(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) HeaderTableSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) InitialWindowSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxConcurrentStreams(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxFrameSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxHeaderListSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) PriorityFrames(priorityFrames []http2.PriorityFrame) *HTTP2Settings
- func (h *HTTP2Settings) PriorityParam(priorityParam http2.PriorityParam) *HTTP2Settings
- func (h *HTTP2Settings) Set() *Builder
- type HTTP3Settings
- type Headers
- type Impersonate
- func (im *Impersonate) Android() *Impersonate
- func (im *Impersonate) Chrome() *Builder
- func (im *Impersonate) FireFox() *Builder
- func (im *Impersonate) IOS() *Impersonate
- func (im *Impersonate) Linux() *Impersonate
- func (im *Impersonate) MacOS() *Impersonate
- func (im *Impersonate) RandomOS() *Impersonate
- func (im *Impersonate) Windows() *Impersonate
- type ImpersonateOS
- type JA
- func (j *JA) Android() *Builder
- func (j *JA) Chrome() *Builder
- func (j *JA) Chrome58() *Builder
- func (j *JA) Chrome62() *Builder
- func (j *JA) Chrome70() *Builder
- func (j *JA) Chrome72() *Builder
- func (j *JA) Chrome83() *Builder
- func (j *JA) Chrome87() *Builder
- func (j *JA) Chrome96() *Builder
- func (j *JA) Chrome100() *Builder
- func (j *JA) Chrome102() *Builder
- func (j *JA) Chrome106() *Builder
- func (j *JA) Chrome120() *Builder
- func (j *JA) Chrome120PQ() *Builder
- func (j *JA) Chrome131() *Builder
- func (j *JA) Edge() *Builder
- func (j *JA) Edge85() *Builder
- func (j *JA) Edge106() *Builder
- func (j *JA) Firefox() *Builder
- func (j *JA) Firefox55() *Builder
- func (j *JA) Firefox56() *Builder
- func (j *JA) Firefox63() *Builder
- func (j *JA) Firefox65() *Builder
- func (j *JA) Firefox99() *Builder
- func (j *JA) Firefox102() *Builder
- func (j *JA) Firefox105() *Builder
- func (j *JA) Firefox120() *Builder
- func (j *JA) Firefox131() *Builder
- func (j *JA) IOS() *Builder
- func (j *JA) IOS11() *Builder
- func (j *JA) IOS12() *Builder
- func (j *JA) IOS13() *Builder
- func (j *JA) IOS14() *Builder
- func (j *JA) Randomized() *Builder
- func (j *JA) RandomizedALPN() *Builder
- func (j *JA) RandomizedNoALPN() *Builder
- func (j *JA) Safari() *Builder
- func (j *JA) SetHelloID(id utls.ClientHelloID) *Builder
- func (j *JA) SetHelloSpec(spec utls.ClientHelloSpec) *Builder
- type Request
- func (req *Request) AddCookies(cookies ...*http.Cookie) *Request
- func (req *Request) AddHeaders(headers ...any) *Request
- func (req *Request) Do() g.Result[*Response]
- func (req *Request) GetRequest() *http.Request
- func (req *Request) SetHeaders(headers ...any) *Request
- func (req *Request) WithContext(ctx context.Context) *Request
- type Response
- func (resp Response) Debug() *Debug
- func (resp Response) GetCookies(rawURL g.String) []*http.Cookie
- func (resp Response) GetResponse() *http.Response
- func (resp Response) Location() g.String
- func (resp Response) Referer() g.String
- func (resp Response) RemoteAddress() net.Addr
- func (resp *Response) SetCookies(rawURL g.String, cookies []*http.Cookie) error
- func (resp Response) TLSGrabber() *TLSData
- type StatusCode
- type TLSData
- type TransportAdapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Body ¶ added in v1.0.51
type Body struct {
Reader io.ReadCloser // ReadCloser for accessing the body content.
// contains filtered or unexported fields
}
Body represents the content and properties of an HTTP response Body.
func (*Body) Contains ¶ added in v1.0.51
Contains checks if the body's content contains the provided pattern (byte slice, string, or *regexp.Regexp) and returns a boolean.
func (*Body) Dump ¶ added in v1.0.51
Dump dumps the body's content to a file with the given filename.
func (*Body) JSON ¶ added in v1.0.51
JSON decodes the body's content as JSON into the provided data structure.
func (*Body) Limit ¶ added in v1.0.51
Limit sets the body's size limit and returns the modified body.
func (*Body) SSE ¶ added in v1.0.53
SSE reads the body's content as Server-Sent Events (SSE) and calls the provided function for each event. It expects the function to take an *sse.Event pointer as its argument and return a boolean value. If the function returns false, the SSE reading stops.
func (*Body) Stream ¶ added in v1.0.51
Stream returns the body's bufio.Reader for streaming the content.
type Builder ¶ added in v1.0.100
type Builder struct {
// contains filtered or unexported fields
}
func (*Builder) AddCookies ¶ added in v1.0.100
AddCookies adds cookies to the request.
func (*Builder) AddHeaders ¶ added in v1.0.100
AddHeaders adds headers to the request, appending to any existing headers with the same name.
func (*Builder) BasicAuth ¶ added in v1.0.100
BasicAuth sets the basic authentication credentials for the client.
func (*Builder) BearerAuth ¶ added in v1.0.100
BearerAuth sets the bearer token for the client.
func (*Builder) Build ¶ added in v1.0.100
Build sets the provided settings for the client and returns the updated client. It configures various settings like HTTP2, sessions, keep-alive, dial TLS, resolver, interface address, timeout, and redirect policy.
func (*Builder) CacheBody ¶ added in v1.0.100
CacheBody configures whether the client should cache the body of the response.
func (*Builder) ContentType ¶ added in v1.0.100
ContentType sets the content type for the client.
func (*Builder) DNSOverTLS ¶ added in v1.0.100
func (b *Builder) DNSOverTLS() *DNSOverTLS
DNSOverTLS configures the client to use DNS over TLS.
func (*Builder) DisableCompression ¶ added in v1.0.100
DisableCompression disables compression for the HTTP client.
func (*Builder) DisableKeepAlive ¶ added in v1.0.100
DisableKeepAlive disable keep-alive connections.
func (*Builder) FollowOnlyHostRedirects ¶ added in v1.0.100
FollowOnlyHostRedirects configures whether the client should only follow redirects within the same host.
func (*Builder) ForceHTTP1 ¶ added in v1.0.100
ForceHTTP1MW configures the client to use HTTP/1.1 forcefully.
func (*Builder) ForwardHeadersOnRedirect ¶ added in v1.0.100
ForwardHeadersOnRedirect adds a middleware to the ClientBuilder object that ensures HTTP headers are forwarded during a redirect.
func (*Builder) GetRemoteAddress ¶ added in v1.0.100
GetRemoteAddress configures whether the client should get the remote address.
func (*Builder) HTTP2Settings ¶ added in v1.0.100
func (b *Builder) HTTP2Settings() *HTTP2Settings
HTTP2Settings configures settings related to HTTP/2 and returns an http2s struct.
func (*Builder) HTTP3 ¶ added in v1.0.101
HTTP3 enables HTTP/3 with automatic browser detection. Settings are applied lazily in Build() based on the impersonated browser. Usage: surf.NewClient().Builder().Impersonate().Chrome().HTTP3().Build()
func (*Builder) HTTP3Settings ¶ added in v1.0.101
func (b *Builder) HTTP3Settings() *HTTP3Settings
HTTP3Settings configures settings related to HTTP/3 and returns an http3s struct.
func (*Builder) Impersonate ¶ added in v1.0.100
func (b *Builder) Impersonate() *Impersonate
Impersonate configures something related to impersonation and returns an impersonate struct.
func (*Builder) InterfaceAddr ¶ added in v1.0.100
InterfaceAddr sets the network interface address for the client.
func (*Builder) MaxRedirects ¶ added in v1.0.100
MaxRedirects sets the maximum number of redirects the client should follow.
func (*Builder) NotFollowRedirects ¶ added in v1.0.100
NotFollowRedirects disables following redirects for the client.
func (*Builder) RedirectPolicy ¶ added in v1.0.100
RedirectPolicy sets a custom redirect policy for the client.
func (*Builder) Retry ¶ added in v1.0.100
Retry configures the retry behavior of the client.
Parameters:
retryMax: Maximum number of retries to be attempted.
retryWait: Duration to wait between retries.
codes: Optional list of HTTP status codes that trigger retries.
If no codes are provided, default codes will be used
(500, 429, 503 - Internal Server Error, Too Many Requests, Service Unavailable).
func (*Builder) Session ¶ added in v1.0.100
Session configures whether the client should maintain a session.
func (*Builder) SetHeaders ¶ added in v1.0.100
SetHeaders sets headers for the request, replacing existing ones with the same name.
func (*Builder) Singleton ¶ added in v1.0.100
Singleton configures the client to use a singleton instance, ensuring there's only one client instance. This is needed specifically for JA or Impersonate functionalities.
cli := surf.NewClient(). Builder(). Singleton(). // for reuse client Impersonate(). FireFox(). Build() defer cli.CloseIdleConnections()
func (Builder) String ¶ added in v1.0.100
String generate a string representation of the ClientBuilder instance.
func (*Builder) UnixDomainSocket ¶ added in v1.0.100
UnixDomainSocket sets the path for a Unix domain socket. This allows the HTTP client to connect to the server using a Unix domain socket instead of a traditional TCP/IP connection.
func (*Builder) With ¶ added in v1.0.100
With adds middleware to the client. It accepts various types of middleware functions and adds them to the client builder.
Parameters:
- middleware: The middleware function to add. It can be one of the following types: 1. func(*surf.Client): Client middleware function, which modifies the client itself. 2. func(*surf.Request) error: Request middleware function, which intercepts and potentially modifies outgoing requests. 3. func(*surf.Response) error: Response middleware function, which intercepts and potentially modifies incoming responses.
- priority (optional): Priority of the middleware. Defaults to 0 if not provided.
If the provided middleware is of an unsupported type, With panics with an error message indicating the invalid middleware type.
Example usage:
// Adding client middleware to modify client settings.
.With(func(client *surf.Client) {
// Custom logic to modify the client settings.
})
// Adding request middleware to intercept outgoing requests.
.With(func(req *surf.Request) error {
// Custom logic to modify outgoing requests.
return nil
})
// Adding response middleware to intercept incoming responses.
.With(func(resp *surf.Response) error {
// Custom logic to handle incoming responses.
return nil
})
Note: Ensure that middleware functions adhere to the specified function signatures to work correctly with the With method.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client struct provides a customizable HTTP client.
func (*Client) Builder ¶ added in v1.0.50
Builder creates a new client builder instance with default values
func (*Client) CloseIdleConnections ¶
func (c *Client) CloseIdleConnections()
CloseIdleConnections removes all entries from the cached transports. Specifically used when Singleton is enabled for JA3 or Impersonate functionalities.
func (*Client) FileUpload ¶
FileUpload creates a new multipart file upload request.
func (*Client) GetTLSConfig ¶
GetTLSConfig returns the tls.Config used by the Client.
func (*Client) GetTransport ¶
func (c *Client) GetTransport() http.RoundTripper
GetTransport returns the http.transport used by the Client.
func (*Client) IsHTTP3 ¶ added in v1.0.101
IsHTTP3 returns true if the client is configured to use HTTP/3.
func (*Client) Raw ¶
Raw creates a new HTTP request using the provided raw data and scheme. The raw parameter should contain the raw HTTP request data as a string. The scheme parameter specifies the scheme (e.g., http, https) for the request.
func (*Client) Std ¶ added in v1.0.100
Std returns a standard net/http.Client that wraps the configured surf client. This is useful for integrating with third-party libraries that expect a standard net/http.Client while preserving most surf features.
Supported features:
- JA3/TLS fingerprinting
- HTTP/2 settings
- Cookies and sessions
- Request/Response middleware
- Headers (User-Agent, custom headers)
- Proxy configuration
- Timeout settings
- Redirect policies
- Impersonate browser headers
Known limitations:
- Retry logic is NOT supported (implemented in Request.Do(), not in transport)
- Response body caching is NOT supported
- Remote address tracking is NOT supported
- Request timing information is NOT available
For applications requiring retry logic, consider implementing it at the application level or use surf.Client directly for those specific requests.
Example usage:
surfClient := surf.NewClient().
Builder().
JA3().Chrome().
Session().
Build()
// For libraries expecting net/http.Client
stdClient := surfClient.Std()
botClient := &BaseBotClient{
Client: *stdClient,
}
type CookieJarAdapter ¶ added in v1.0.100
type CookieJarAdapter struct {
// contains filtered or unexported fields
}
CookieJarAdapter adapts github.com/enetx/http.CookieJar to net/http.CookieJar. It provides bidirectional cookie conversion between the two HTTP packages, ensuring cookies set through either interface work correctly.
func (*CookieJarAdapter) Cookies ¶ added in v1.0.100
func (c *CookieJarAdapter) Cookies(u *url.URL) []*_http.Cookie
Cookies implements http.CookieJar interface. It retrieves cookies from the underlying surf cookie jar and converts them to standard net/http cookie format.
func (*CookieJarAdapter) SetCookies ¶ added in v1.0.100
func (c *CookieJarAdapter) SetCookies(u *url.URL, _cookies []*_http.Cookie)
SetCookies implements http.CookieJar interface. It converts standard net/http cookies to enetx/http format and delegates to the underlying surf cookie jar.
type Cookies ¶ added in v1.0.51
Cookies represents a list of HTTP Cookies.
type DNSOverTLS ¶ added in v1.0.100
type DNSOverTLS struct {
// contains filtered or unexported fields
}
DNSOverTLS is a configuration struct for DNS over TLS settings.
func (*DNSOverTLS) AdGuard ¶ added in v1.0.100
func (dot *DNSOverTLS) AdGuard() *Builder
AdGuard sets up DNS over TLS with AdGuard DNS.
func (*DNSOverTLS) AddProvider ¶ added in v1.0.100
AddProvider sets up DNS over TLS with a custom DNS provider. It configures a custom net.Resolver using the resolver method.
func (*DNSOverTLS) Ali ¶ added in v1.0.100
func (dot *DNSOverTLS) Ali() *Builder
Ali sets up DNS over TLS with AliDNS.
func (*DNSOverTLS) CIRAShield ¶ added in v1.0.100
func (dot *DNSOverTLS) CIRAShield() *Builder
CIRAShield sets up DNS over TLS with CIRA Canadian Shield DNS.
func (*DNSOverTLS) Cloudflare ¶ added in v1.0.100
func (dot *DNSOverTLS) Cloudflare() *Builder
Cloudflare sets up DNS over TLS with Cloudflare DNS.
func (*DNSOverTLS) Forge ¶ added in v1.0.100
func (dot *DNSOverTLS) Forge() *Builder
Forge sets up DNS over TLS with DNS Forge.
func (*DNSOverTLS) Google ¶ added in v1.0.100
func (dot *DNSOverTLS) Google() *Builder
Google sets up DNS over TLS with Google Public DNS.
func (*DNSOverTLS) LibreDNS ¶ added in v1.0.100
func (dot *DNSOverTLS) LibreDNS() *Builder
LibreDNS sets up DNS over TLS with LibreDNS.
func (*DNSOverTLS) Quad9 ¶ added in v1.0.100
func (dot *DNSOverTLS) Quad9() *Builder
Quad9 sets up DNS over TLS with Quad9 DNS.
func (*DNSOverTLS) Quad101 ¶ added in v1.0.100
func (dot *DNSOverTLS) Quad101() *Builder
Quad101 sets up DNS over TLS with Quad101 DNS.
func (*DNSOverTLS) SB ¶ added in v1.0.100
func (dot *DNSOverTLS) SB() *Builder
SB sets up DNS over TLS with Secure DNS (dot.sb).
func (*DNSOverTLS) Switch ¶ added in v1.0.100
func (dot *DNSOverTLS) Switch() *Builder
Switch sets up DNS over TLS with SWITCH DNS.
type Debug ¶ added in v1.0.100
type Debug struct {
// contains filtered or unexported fields
}
Debug is a struct that holds debugging information for an HTTP response.
type Err101ResponseCode ¶ added in v1.0.100
type Err101ResponseCode struct{ Msg string }
func (*Err101ResponseCode) Error ¶ added in v1.0.100
func (e *Err101ResponseCode) Error() string
type ErrUserAgentType ¶ added in v1.0.100
type ErrUserAgentType struct{ Msg string }
func (*ErrUserAgentType) Error ¶ added in v1.0.100
func (e *ErrUserAgentType) Error() string
type ErrWebSocketUpgrade ¶ added in v1.0.100
type ErrWebSocketUpgrade struct{ Msg string }
func (*ErrWebSocketUpgrade) Error ¶ added in v1.0.100
func (e *ErrWebSocketUpgrade) Error() string
type HTTP2Settings ¶ added in v1.0.100
type HTTP2Settings struct {
// contains filtered or unexported fields
}
HTTP2Settings represents HTTP/2 settings. https://lwthiker.com/networks/2022/06/17/http2-fingerprinting.html
func (*HTTP2Settings) ConnectionFlow ¶ added in v1.0.100
func (h *HTTP2Settings) ConnectionFlow(size uint32) *HTTP2Settings
ConnectionFlow sets the flow control for the HTTP/2 connection.
func (*HTTP2Settings) EnablePush ¶ added in v1.0.100
func (h *HTTP2Settings) EnablePush(size uint32) *HTTP2Settings
EnablePush enables HTTP/2 server push functionality.
func (*HTTP2Settings) HeaderTableSize ¶ added in v1.0.100
func (h *HTTP2Settings) HeaderTableSize(size uint32) *HTTP2Settings
HeaderTableSize sets the header table size for HTTP/2 settings.
func (*HTTP2Settings) InitialWindowSize ¶ added in v1.0.100
func (h *HTTP2Settings) InitialWindowSize(size uint32) *HTTP2Settings
InitialWindowSize sets the initial window size for HTTP/2 streams.
func (*HTTP2Settings) MaxConcurrentStreams ¶ added in v1.0.100
func (h *HTTP2Settings) MaxConcurrentStreams(size uint32) *HTTP2Settings
MaxConcurrentStreams sets the maximum number of concurrent streams in HTTP/2.
func (*HTTP2Settings) MaxFrameSize ¶ added in v1.0.100
func (h *HTTP2Settings) MaxFrameSize(size uint32) *HTTP2Settings
MaxFrameSize sets the maximum frame size for HTTP/2 frames.
func (*HTTP2Settings) MaxHeaderListSize ¶ added in v1.0.100
func (h *HTTP2Settings) MaxHeaderListSize(size uint32) *HTTP2Settings
MaxHeaderListSize sets the maximum size of the header list in HTTP/2.
func (*HTTP2Settings) PriorityFrames ¶ added in v1.0.100
func (h *HTTP2Settings) PriorityFrames(priorityFrames []http2.PriorityFrame) *HTTP2Settings
PriorityFrames sets the priority frames for HTTP/2.
func (*HTTP2Settings) PriorityParam ¶ added in v1.0.100
func (h *HTTP2Settings) PriorityParam(priorityParam http2.PriorityParam) *HTTP2Settings
PriorityParam sets the priority parameter for HTTP/2.
func (*HTTP2Settings) Set ¶ added in v1.0.100
func (h *HTTP2Settings) Set() *Builder
Set applies the accumulated HTTP/2 settings. It configures the HTTP/2 settings for the surf client.
type HTTP3Settings ¶ added in v1.0.101
type HTTP3Settings struct {
// contains filtered or unexported fields
}
HTTP3Settings represents HTTP/3 settings with uQUIC fingerprinting support. https://github.com/refraction-networking/uquic
func (*HTTP3Settings) Chrome ¶ added in v1.0.101
func (h *HTTP3Settings) Chrome() *HTTP3Settings
Chrome configures HTTP/3 settings to mimic Chrome browser.
func (*HTTP3Settings) Firefox ¶ added in v1.0.101
func (h *HTTP3Settings) Firefox() *HTTP3Settings
Firefox configures HTTP/3 settings to mimic Firefox browser.
func (*HTTP3Settings) Set ¶ added in v1.0.101
func (h *HTTP3Settings) Set() *Builder
Set applies the accumulated HTTP/3 settings. It configures the uQUIC transport for the surf client.
func (*HTTP3Settings) SetQUICID ¶ added in v1.0.101
func (h *HTTP3Settings) SetQUICID(quicID uquic.QUICID) *HTTP3Settings
SetQUICID sets a custom QUIC ID for fingerprinting.
func (*HTTP3Settings) SetQUICSpec ¶ added in v1.0.101
func (h *HTTP3Settings) SetQUICSpec(quicSpec uquic.QUICSpec) *HTTP3Settings
SetQUICSpec sets a custom QUIC spec for advanced fingerprinting.
type Headers ¶ added in v1.0.51
Headers represents a collection of HTTP Headers.
func (Headers) Contains ¶ added in v1.0.51
Contains checks if the header contains any of the specified patterns. It accepts a header name and a pattern (or list of patterns) and returns a boolean value indicating whether any of the patterns are found in the header values. The patterns can be a string, a slice of strings, or a slice of *regexp.Regexp.
type Impersonate ¶ added in v1.0.100
type Impersonate struct {
// contains filtered or unexported fields
}
func (*Impersonate) Android ¶ added in v1.0.100
func (im *Impersonate) Android() *Impersonate
Android sets the OS to Android.
func (*Impersonate) Chrome ¶ added in v1.0.100
func (im *Impersonate) Chrome() *Builder
Chrome impersonates Chrome browser v.131.
func (*Impersonate) FireFox ¶ added in v1.0.100
func (im *Impersonate) FireFox() *Builder
Firefox impersonates Firefox browser v.131.
func (*Impersonate) IOS ¶ added in v1.0.100
func (im *Impersonate) IOS() *Impersonate
IOS sets the OS to iOS.
func (*Impersonate) Linux ¶ added in v1.0.100
func (im *Impersonate) Linux() *Impersonate
Linux sets the OS to Linux.
func (*Impersonate) MacOS ¶ added in v1.0.100
func (im *Impersonate) MacOS() *Impersonate
MacOS sets the OS to macOS.
func (*Impersonate) RandomOS ¶ added in v1.0.100
func (im *Impersonate) RandomOS() *Impersonate
RandomOS selects a random OS (Windows, macOS, Linux, Android, or iOS) for the impersonate.
func (*Impersonate) Windows ¶ added in v1.0.100
func (im *Impersonate) Windows() *Impersonate
Windows sets the OS to Windows.
type ImpersonateOS ¶ added in v1.0.100
type ImpersonateOS int
ImpersonateOS defines the operating system to impersonate in User-Agent strings.
type JA ¶ added in v1.0.100
type JA struct {
// contains filtered or unexported fields
}
https://lwthiker.com/networks/2022/06/17/tls-fingerprinting.html
func (*JA) Chrome120PQ ¶ added in v1.0.100
func (*JA) Firefox102 ¶ added in v1.0.100
func (*JA) Firefox105 ¶ added in v1.0.100
func (*JA) Firefox120 ¶ added in v1.0.100
func (*JA) Firefox131 ¶ added in v1.0.100
func (*JA) Randomized ¶ added in v1.0.100
func (*JA) RandomizedALPN ¶ added in v1.0.100
func (*JA) RandomizedNoALPN ¶ added in v1.0.100
func (*JA) SetHelloID ¶ added in v1.0.100
func (j *JA) SetHelloID(id utls.ClientHelloID) *Builder
SetHelloID sets a ClientHelloID for the TLS connection.
The provided ClientHelloID is used to customize the TLS handshake. This should be a valid identifier that can be mapped to a specific ClientHelloSpec.
It returns a pointer to the Options struct for method chaining. This allows additional configuration methods to be called on the result.
Example usage:
JA().SetHelloID(utls.HelloChrome_Auto)
func (*JA) SetHelloSpec ¶ added in v1.0.100
func (j *JA) SetHelloSpec(spec utls.ClientHelloSpec) *Builder
SetHelloSpec sets a custom ClientHelloSpec for the TLS connection.
This method allows you to set a custom ClientHelloSpec to be used during the TLS handshake. The provided spec should be a valid ClientHelloSpec.
It returns a pointer to the Options struct for method chaining. This allows additional configuration methods to be called on the result.
Example usage:
JA().SetHelloSpec(spec)
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is a struct that holds information about an HTTP request.
func (*Request) AddCookies ¶
AddCookies adds cookies to the request.
func (*Request) AddHeaders ¶
AddHeaders adds headers to the request, appending to any existing headers with the same name.
func (*Request) Do ¶
Do performs the HTTP request and returns a Response object or an error if the request failed.
func (*Request) GetRequest ¶
GetRequest returns the underlying http.Request of the custom request.
func (*Request) SetHeaders ¶
SetHeaders sets headers for the request, replacing existing ones with the same name.
type Response ¶
type Response struct {
*Client // Client is the associated client for the response.
URL *url.URL // URL of the response.
Body *Body // Response body.
Headers Headers // Response headers.
UserAgent g.String // User agent string.
Proto g.String // HTTP protocol version.
Cookies Cookies // Response cookies.
Time time.Duration // Total time taken for the response.
ContentLength int64 // Length of the response content.
StatusCode StatusCode // HTTP status code.
Attempts int // Number of attempts made.
// contains filtered or unexported fields
}
Response represents a custom response structure.
func (Response) GetCookies ¶
GetCookies returns the cookies from the response for the given URL.
func (Response) GetResponse ¶
GetResponse returns the underlying http.Response of the custom response.
func (Response) RemoteAddress ¶
RemoteAddress returns the remote address of the response.
func (*Response) SetCookies ¶
SetCookies sets cookies for the given URL in the response.
func (Response) TLSGrabber ¶
TLSGrabber returns a tlsData struct containing information about the TLS connection if it exists.
type StatusCode ¶ added in v1.0.47
type StatusCode int
StatusCode represents an HTTP status code.
func (StatusCode) IsClientError ¶ added in v1.0.47
func (s StatusCode) IsClientError() bool
IsClientError returns true if the status code indicates a client error [400, 500].
func (StatusCode) IsInformational ¶ added in v1.0.47
func (s StatusCode) IsInformational() bool
IsInformational returns true if the status code is in the informational range [100, 200].
func (StatusCode) IsRedirection ¶ added in v1.0.47
func (s StatusCode) IsRedirection() bool
IsRedirection returns true if the status code indicates a redirection [300, 400].
func (StatusCode) IsServerError ¶ added in v1.0.47
func (s StatusCode) IsServerError() bool
IsServerError returns true if the status code indicates a server error [500, ∞].
func (StatusCode) IsSuccess ¶ added in v1.0.47
func (s StatusCode) IsSuccess() bool
IsSuccess returns true if the status code indicates a successful response [200, 300].
func (StatusCode) Text ¶ added in v1.0.47
func (s StatusCode) Text() string
Text returns the textual representation of the status code.
type TLSData ¶ added in v1.0.100
type TLSData struct {
ExtensionServerName string // Server name extension of the TLS certificate.
FingerprintSHA256 string // SHA-256 fingerprint of the certificate.
FingerprintSHA256OpenSSL string // SHA-256 fingerprint compatible with OpenSSL.
TLSVersion string // TLS version used.
CommonName []string // List of common names associated with the certificate.
DNSNames []string // List of DNS names associated with the certificate.
Emails []string // List of email addresses associated with the certificate.
IssuerCommonName []string // List of common names of the certificate issuer.
IssuerOrg []string // List of organizations of the certificate issuer.
Organization []string // List of organizations associated with the certificate.
}
TLSData represents information about a TLS certificate.
type TransportAdapter ¶ added in v1.0.100
type TransportAdapter struct {
// contains filtered or unexported fields
}
TransportAdapter adapts surf.Client to net/http.RoundTripper It uses the full surf pipeline including middleware
func (*TransportAdapter) CloseIdleConnections ¶ added in v1.0.100
func (s *TransportAdapter) CloseIdleConnections()
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
std
command
|
|
|
internal
|
|
|
pkg
|
|
|
quicconn
Package quicconn provides a net.PacketConn adapter for feeding QUIC stacks (such as quic-go) with datagrams originating from a generic net.Conn.
|
Package quicconn provides a net.PacketConn adapter for feeding QUIC stacks (such as quic-go) with datagrams originating from a generic net.Conn. |