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
- func (d *Dialer) Dial(network, addr string) (conn net.Conn, err error)
- func (d *Dialer) DialTimeout(network, addr string, timeout time.Duration) (conn net.Conn, err error)
- func (d *Dialer) GetDialFunc(useEnv bool) (dialFunc fasthttp.DialFunc, err error)
- func (d *Dialer) GetDialTimeoutFunc(useEnv bool) (dialFunc TimeoutDial, err error)
- type DialerFunc
- type DialerV2
- type TimeoutDial
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FasthttpHTTPDialer ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 // 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 // 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 }
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) DialTimeout ¶
func (*Dialer) GetDialFunc ¶
GetDialFunc method returns a fasthttp-style dial function. The useEnv parameter determines whether the proxy address comes from Dialer.Config or from environment variables.
func (*Dialer) GetDialTimeoutFunc ¶
func (d *Dialer) GetDialTimeoutFunc(useEnv bool) (dialFunc TimeoutDial, err error)
GetDialTimeoutFunc 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 ¶
DialerFunc Make a function of type func(network, addr string) (net.Conn, error) implement the proxy.Dialer interface.