Documentation
¶
Index ¶
- func FasthttpHTTPDialer(proxy string) fasthttp.DialFunc
- func FasthttpHTTPDialerTimeout(proxy string, timeout time.Duration) fasthttp.DialFunc
- func FasthttpProxyHTTPDialer() fasthttp.DialFunc
- func FasthttpProxyHTTPDialerTimeout(timeout time.Duration) fasthttp.DialFunc
- func FasthttpSocksDialer(proxyAddr string) fasthttp.DialFunc
- type Dialer
- type DialerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FasthttpHTTPDialer ¶ added in v1.12.0
FasthttpHTTPDialer returns a fasthttp.DialFunc that dials using the provided HTTP proxy.
Example usage:
c := &fasthttp.Client{
Dial: fasthttpproxy.FasthttpHTTPDialer("username:password@localhost:9050"),
}
func FasthttpHTTPDialerTimeout ¶ added in v1.17.0
FasthttpHTTPDialerTimeout returns a fasthttp.DialFunc that dials using the provided HTTP proxy using the given timeout. The timeout parameter determines both the dial timeout and the CONNECT request timeout.
Example usage:
c := &fasthttp.Client{
Dial: fasthttpproxy.FasthttpHTTPDialerTimeout("username:password@localhost:9050", time.Second * 2),
}
func FasthttpProxyHTTPDialer ¶ added in v1.17.0
FasthttpProxyHTTPDialer returns a fasthttp.DialFunc that dials using the env(HTTP_PROXY, HTTPS_PROXY and NO_PROXY) configured HTTP proxy.
Example usage:
c := &fasthttp.Client{
Dial: fasthttpproxy.FasthttpProxyHTTPDialer(),
}
func FasthttpProxyHTTPDialerTimeout ¶ added in v1.17.0
FasthttpProxyHTTPDialerTimeout returns a fasthttp.DialFunc that dials using the env(HTTP_PROXY, HTTPS_PROXY and NO_PROXY) configured HTTP proxy using the given timeout. The timeout parameter determines both the dial timeout and the CONNECT request timeout.
Example usage:
c := &fasthttp.Client{
Dial: fasthttpproxy.FasthttpProxyHTTPDialerTimeout(time.Second * 2),
}
func FasthttpSocksDialer ¶
FasthttpSocksDialer returns a fasthttp.DialFunc that dials using the provided SOCKS5 proxy.
Example usage:
c := &fasthttp.Client{
Dial: fasthttpproxy.FasthttpSocksDialer("socks5://localhost:9050"),
}
Types ¶
type Dialer ¶ added in v1.56.0
type Dialer struct {
fasthttp.TCPDialer
// Support HTTPProxy, HTTPSProxy and NoProxy configuration.
//
// HTTPProxy represents the value of the HTTP_PROXY or
// http_proxy environment variable. It will be used as the proxy
// URL for HTTP requests unless overridden by NoProxy.
//
// HTTPSProxy represents the HTTPS_PROXY or https_proxy
// environment variable. It will be used as the proxy URL for
// HTTPS requests unless overridden by NoProxy.
//
// NoProxy represents the NO_PROXY or no_proxy environment
// variable. It specifies a string that contains comma-separated values
// specifying hosts that should be excluded from proxying. Each value is
// represented by an IP address prefix (1.2.3.4), an IP address prefix in
// CIDR notation (1.2.3.4/8), a domain name, or a special DNS label (*).
// An IP address prefix and domain name can also include a literal port
// number (1.2.3.4:80).
// A domain name matches that name and all subdomains. A domain name with
// a leading "." matches subdomains only. For example "foo.com" matches
// "foo.com" and "bar.foo.com"; ".y.com" matches "x.y.com" but not "y.com".
// A single asterisk (*) indicates that no proxying should be done.
// A best effort is made to parse the string and errors are
// ignored.
httpproxy.Config
// Attempt to connect to both ipv4 and ipv6 addresses if set to true.
// By default, dial only to ipv4 addresses,
// since unfortunately ipv6 remains broken in many networks worldwide :)
//
// This field from the fasthttp client is provided redundantly here because
// when we customize the Dial function for the client, its DialDualStack field
// configuration becomes ineffective.
DialDualStack bool
// Dial timeout.
//
// This field from the fasthttp client is provided redundantly here because
// when we customize the Dial function for the client, its DialTimeout field
// configuration becomes ineffective.
Timeout time.Duration
// The timeout for sending a CONNECT request when using an HTTP proxy.
ConnectTimeout time.Duration
}
Dialer embeds both fasthttp.TCPDialer and httpproxy.Config, allowing it to take advantage of the optimizations provided by fasthttp for dialing while also utilizing the finer-grained configuration options offered by httpproxy.
func (*Dialer) GetDialFunc ¶ added in v1.56.0
GetDialFunc method returns a fasthttp-style dial function. The useEnv parameter determines whether the proxy address comes from Dialer.Config or from environment variables.
type DialerFunc ¶ added in v1.56.0
DialerFunc Make a function of type func(network, addr string) (net.Conn, error) implement the proxy.Dialer interface.