Documentation
¶
Overview ¶
Package netproxy sends Go's HTTP requests through the proxy the user set in the system's settings, as browsers and the app's web pages do, with its bypass list and automatic configuration (PAC files, WPAD):
client := &http.Client{Transport: netproxy.Transport()}
MyGo's own requests go this way: the updater's, and those of the fetch and websocket plugins unless their options name a client.
Proxy decides, for each request:
- Loopback hosts (localhost, *.localhost, 127.0.0.0/8, ::1) are reached directly.
- When any of HTTP_PROXY, HTTPS_PROXY, ALL_PROXY or NO_PROXY (or its lowercase name) is set, the environment decides, as http.ProxyFromEnvironment does: an explicit setting wins over the system's.
- Otherwise the system's settings for the URL do: WinHTTP's reading of the user's settings on Windows, with automatic detection and PAC files; CFNetwork's on macOS, with PAC files; GIO's default proxy resolver on Linux, which reads GNOME's settings, or KDE's and PAC files through libproxy. Where none answers, requests go direct.
The system's answer for a scheme and host is kept for 5 seconds, so a change of the settings applies to the requests that follow without restarting the app. Requests under way keep their connections, and Go's transport keys idle connections by their proxy, so none opened through the previous proxy is reused for the new one.
Go's transport speaks to HTTP and HTTPS proxies and to SOCKS5: a SOCKS proxy of unknown version is taken for SOCKS5, and SOCKS4 proxies are skipped. A proxy's password is sent only when the system's answer holds it, as GNOME's settings can. In browsers (js/wasm) the browser makes the requests, with its own proxy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.