Documentation
¶
Overview ¶
Package sysproxy teaches Go's default HTTP transport to honour the proxy configured in the operating system.
A GUI app started by Finder, the Dock or a login item inherits no HTTP_PROXY/HTTPS_PROXY/NO_PROXY variables, so http.ProxyFromEnvironment sees no proxy and every request goes direct. Install replaces the default transport's Proxy with Func, which keeps the environment when it is set and otherwise reads the system settings (macOS scutil, Windows Internet Settings; Linux has no system-wide proxy Go can read).
The system lookup is cached for cacheTTL, so toggling the system proxy is picked up without restarting the app, and every platform implementation bounds its work (macOS kills scutil after two seconds) and falls back to a direct connection on any error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Func ¶
Func is the proxy selector Install installs. It follows HTTP_PROXY, HTTPS_PROXY and NO_PROXY when any of them is set, and otherwise asks the operating system. It never proxies a loopback address and never returns an error: an unavailable system proxy means a direct connection.
Code that builds its own transport instead of using http.DefaultTransport can assign Func to that transport's Proxy field.
Types ¶
This section is empty.