Documentation
¶
Overview ¶
Package proxy provides support for a variety of protocols to proxy network data.
Package proxy safe map Code generated by mapgen (https://github.com/ammario/mapgen), DO NOT EDIT.
Index ¶
- Variables
- func RegisterDialerType(scheme string, f func(*url.URL, Dialer) (Dialer, error))
- type Auth
- type Dialer
- type HTTPProxyHandler
- type PerHost
- func (p *PerHost) AddCIDR(net *net.IPNet)
- func (p *PerHost) AddDOMAIN(domain string)
- func (p *PerHost) AddFromString(s string)
- func (p *PerHost) AddIP(ip net.IP)
- func (p *PerHost) AddKEYWORD(keyword string)
- func (p *PerHost) AddSUFFIX(suffix string)
- func (p *PerHost) Dial(network, addr string) (c net.Conn, err error)
- type StringBoolMap
- func (m *StringBoolMap) Copy() (c map[string]bool)
- func (m *StringBoolMap) Delete(key string)
- func (m *StringBoolMap) Exists(key string) bool
- func (m *StringBoolMap) Get(key string) bool
- func (m *StringBoolMap) GetEx(key string) (bool, bool)
- func (m *StringBoolMap) Len() int
- func (m *StringBoolMap) Open(f func())
- func (m *StringBoolMap) Set(key string, val bool)
- func (m *StringBoolMap) SetIfNotExist(key string, val bool) bool
Constants ¶
This section is empty.
Variables ¶
var Direct = direct{}
Direct is a direct proxy: one that makes network connections directly.
var ErrBlockedHost = errors.New("host is blocked")
var ErrNonHijackableWriter = errors.New("failed to acquire raw client connection: writer is not hijackable")
ErrNonHijackableWriter is an error that is returned when the connection cannot be hijacked.
Functions ¶
Types ¶
type Auth ¶
type Auth struct {
User, Password string
}
Auth contains authentication parameters that specific Dialers may require.
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.
func FromEnvironment ¶
func FromEnvironment() Dialer
FromEnvironment returns the dialer specified by the proxy related variables in the environment.
type HTTPProxyHandler ¶
type HTTPProxyHandler struct { // Dialer is the dialer for connecting to the SOCKS5 proxy. Dialer proxy.Dialer UserAgent string }
HTTPProxyHandler is a proxy handler that passes on request to a SOCKS5 proxy server.
func (*HTTPProxyHandler) ServeHTTP ¶
func (h *HTTPProxyHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)
type PerHost ¶
type PerHost struct {
// contains filtered or unexported fields
}
A PerHost directs connections to a default Dialer unless the hostname 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) AddCIDR ¶
AddCIDR 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) AddDOMAIN ¶
AddDOMAIN 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) 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 hostname (localhost). A best effort is made to parse the string and errors are ignored.
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) AddKEYWORD ¶
AddKEYWORD 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.
type StringBoolMap ¶
type StringBoolMap struct { sync.RWMutex // M contains the underlying map. // Goroutines which access M directly should hold // the mutex. M map[string]bool }
StringBoolMap is a generated thread safe map with key string and value bool
func NewStringBoolMap ¶
func NewStringBoolMap() *StringBoolMap
NewStringBoolMap returns an instantiated thread safe map with key string and value bool
func (*StringBoolMap) Copy ¶
func (m *StringBoolMap) Copy() (c map[string]bool)
Copy generates a copy of the map.
func (*StringBoolMap) Delete ¶
func (m *StringBoolMap) Delete(key string)
Delete removes a key from the map
func (*StringBoolMap) Exists ¶
func (m *StringBoolMap) Exists(key string) bool
Exists returns if a key exists
func (*StringBoolMap) Get ¶
func (m *StringBoolMap) Get(key string) bool
Get retrieves a key from the map
func (*StringBoolMap) GetEx ¶
func (m *StringBoolMap) GetEx(key string) (bool, bool)
GetEx retrieves a key from the map and whether it exists
func (*StringBoolMap) Open ¶
func (m *StringBoolMap) Open(f func())
Open allows a closure to safely operate on the map
func (*StringBoolMap) Set ¶
func (m *StringBoolMap) Set(key string, val bool)
Set sets a key on the map
func (*StringBoolMap) SetIfNotExist ¶
func (m *StringBoolMap) SetIfNotExist(key string, val bool) bool
SetIfNotExist sets a key on the map if it doesn't exist. It returns the value which is set.