type Config … type config … // FromEnvironment returns a Config instance populated from the // environment variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY (or the // lowercase versions thereof). // // The environment values may be either a complete URL or a // "host[:port]", in which case the "http" scheme is assumed. An error // is returned if the value is a different form. func FromEnvironment() *Config { … } func getEnvAny(names ...string) string { … } // ProxyFunc returns a function that determines the proxy URL to use for // a given request URL. Changing the contents of cfg will not affect // proxy functions created earlier. // // A nil URL and nil error are returned if no proxy is defined in the // environment, or a proxy should not be used for the given request, as // defined by NO_PROXY. // // As a special case, if req.URL.Host is "localhost" or a loopback address // (with or without a port number), then a nil URL and nil error will be returned. func (cfg *Config) ProxyFunc() func(reqURL *url.URL) (*url.URL, error) { … } func (cfg *config) proxyForURL(reqURL *url.URL) (*url.URL, error) { … } func parseProxy(proxy string) (*url.URL, error) { … } // useProxy reports whether requests to addr should use a proxy, // according to the NO_PROXY or no_proxy environment variable. // addr is always a canonicalAddr with a host and port. func (cfg *config) useProxy(addr string) bool { … } func (c *config) init() { … } var portMap … // canonicalAddr returns url.Host but always with a ":port" suffix func canonicalAddr(url *url.URL) string { … } // Given a string of the form "host", "host:port", or "[ipv6::address]:port", // return true if the string includes a port. func hasPort(s string) bool { … } func idnaASCII(v string) (string, error) { … } func isASCII(s string) bool { … } type matcher … type allMatch … func (a allMatch) match(host, port string, ip net.IP) bool { … } type cidrMatch … func (m cidrMatch) match(host, port string, ip net.IP) bool { … } type ipMatch … func (m ipMatch) match(host, port string, ip net.IP) bool { … } type domainMatch … func (m domainMatch) match(host, port string, ip net.IP) bool { … }