Documentation
¶
Overview ¶
Package netproxy selects, per request, whether the global proxy configured under network.proxy receives the request or the request connects directly. The selector is pure: it never reads the environment, so a configured proxy replaces (rather than mixes with) HTTP_PROXY/HTTPS_PROXY/NO_PROXY.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseProxyURL ¶
ParseProxyURL validates network.proxy.url: an http://, https:// or socks5:// URL with a host. The value may carry credentials (keep them in ${VAR}); it is deliberately not part of the error text, which reaches logs and traces.
func ParseSites ¶
ParseSites validates every network.proxy.sites entry: "*", a host, a leading-dot suffix (".example.com" covers the domain and its subdomains) or a host:port. Paths and schemes are rejected, so a list can only name hosts.
Types ¶
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector routes requests whose target host is on the allowlist through one fixed proxy URL and lets every other request connect directly. It is immutable and safe for concurrent use; a nil Selector selects nothing.
func New ¶
New validates a proxy URL and its site allowlist. The URL is required; sites may be empty, which opts no host in (an empty list never means "everything": write "*" for that).
func (*Selector) Match ¶
Match reports whether u is on the allowlist and therefore goes through the proxy. Only the URL's host and port are used; no DNS resolution is involved.