Documentation ¶
Overview ¶
Package proxy provides support for a variety of protocols to proxy network data.
Index ¶
- Variables
- func Dial(ctx context.Context, network, address string) (net.Conn, error)
- func RegisterDialerType(scheme string, f func(*url.URL, Dialer) (Dialer, error))
- type Auth
- type ContextDialer
- type Dialer
- type PerHost
- func (p *PerHost) AddFromString(s string)
- func (p *PerHost) AddHost(host string)
- func (p *PerHost) AddIP(ip net.IP)
- func (p *PerHost) AddNetwork(net *net.IPNet)
- func (p *PerHost) AddZone(zone string)
- func (p *PerHost) Dial(network, addr string) (c net.Conn, err error)
- func (p *PerHost) DialContext(ctx context.Context, network, addr string) (c net.Conn, err error)
Constants ¶
This section is empty.
Variables ¶
var Direct = direct{}
Direct implements Dialer by making network connections directly using net.Dial or net.DialContext.
Functions ¶
func Dial ¶
Dial works like DialContext on net.Dialer but using a dialer returned by FromEnvironment.
The passed ctx is only used for returning the Conn, not the lifetime of the Conn.
Custom dialers (registered via RegisterDialerType) that do not implement ContextDialer can leak a goroutine for as long as it takes the underlying Dialer implementation to timeout.
A Conn returned from a successful Dial after the context has been cancelled will be immediately closed.
Types ¶
type Auth ¶
type Auth struct {
User, Password string
}
Auth contains authentication parameters that specific Dialers may require.
type ContextDialer ¶
type ContextDialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
A ContextDialer dials using a context.
type Dialer ¶
type Dialer interface { // Dial connects to the given address via the proxy. Dial(network, addr string) (c net.Conn, err error) }
A Dialer is a means to establish a connection. Custom dialers should also implement ContextDialer.
func FromEnvironment ¶
func FromEnvironment() Dialer
FromEnvironment returns the dialer specified by the proxy-related variables in the environment and makes underlying connections directly.
func FromEnvironmentUsing ¶
FromEnvironmentUsing returns the dialer specify by the proxy-related variables in the environment and makes underlying connections using the provided forwarding Dialer (for instance, a *net.Dialer with desired configuration).
func FromURL ¶
FromURL returns a Dialer given a URL specification and an underlying Dialer for it to make network requests.
type PerHost ¶
type PerHost struct {
// contains filtered or unexported fields
}
A PerHost directs connections to a default Dialer unless the host name requested matches one of a number of exceptions.
func NewPerHost ¶
NewPerHost returns a PerHost Dialer that directs connections to either defaultDialer or bypass, depending on whether the connection matches one of the configured rules.
func (*PerHost) AddFromString ¶
AddFromString parses a string that contains comma-separated values specifying hosts that should use the bypass proxy. Each value is either an IP address, a CIDR range, a zone (*.example.com) or a host name (localhost). A best effort is made to parse the string and errors are ignored.
func (*PerHost) AddHost ¶
AddHost specifies a host name that will use the bypass proxy.
func (*PerHost) AddIP ¶
AddIP specifies an IP address that will use the bypass proxy. Note that this will only take effect if a literal IP address is dialed. A connection to a named host will never match an IP.
func (*PerHost) AddNetwork ¶
AddNetwork specifies an IP range that will use the bypass proxy. Note that this will only take effect if a literal IP address is dialed. A connection to a named host will never match.
func (*PerHost) AddZone ¶
AddZone specifies a DNS suffix that will use the bypass proxy. A zone of "example.com" matches "example.com" and all of its subdomains.
func (*PerHost) Dial ¶
Dial connects to the address addr on the given network through either defaultDialer or bypass.