Struct system_proxy::SystemProxyResolver
source · [−]pub struct SystemProxyResolver { /* private fields */ }Expand description
The system proxy resolver.
Resolve proxies from system configuration, and through operating system APIs.
Implementations
sourceimpl SystemProxyResolver
impl SystemProxyResolver
sourcepub fn new(env_proxies: EnvProxies, env_no_proxy: EnvNoProxy) -> Self
pub fn new(env_proxies: EnvProxies, env_no_proxy: EnvNoProxy) -> Self
Create a new system proxy resolver.
Creates an instance of the standard proxy resolver for the current operating system and uses the given environment proxy settings.
sourcepub fn no_env() -> Self
pub fn no_env() -> Self
Create a system proxy resolver which never looks at the environment.
This resolver will only use the standard proxy resolver of the operating system.
sourcepub fn for_url(&self, url: &Url) -> Option<Url>
pub fn for_url(&self, url: &Url) -> Option<Url>
Resolve system proxy to use for url.
Return the proxy URL to use or None for a direct connection.
Environment
On all systems this resolver first looks at the proxy settings in the environment, per
env::EnvProxies and env::EnvNoProxy.
The proxies specified in the environment take precedence over the system proxy, and the
system proxy is not consulted for URLs that match the env::EnvNoProxy settings.
This allows to quickly disable all proxying for a given application by setting $no_proxy
to *, even if the appliation looks up a system proxy.
Operating system proxy resolver
Linux and other unix systems
On Linux and other Unix systems this function checks Gnome’s proxy configuration through
the Gio API, if the corresponding gio feature is enabled (default). This enables support
for more advanced proxy configuration schemes, in particular PAC URLs for proxy
configuration.
MacOS
MacOS is not supported currently. Pull requests welcome.
Windows
On Windows this function uses the WinHTTP API to resolve the Windows system proxy configuration. However it disables automatic resolution of PAC URLs through DHCP or DNS queries in the local network; this can take several seconds and shouldn’t be done synchronously. If you require support for this kind of setup please refer to the async API.
Trait Implementations
sourceimpl Default for SystemProxyResolver
impl Default for SystemProxyResolver
sourcefn default() -> Self
fn default() -> Self
Create the default system proxy resolver.
This proxy resolver uses the curl environment by default (see
env::EnvProxies::from_curl_env() and env::EnvNoProxy::from_curl_env()) by default
and falls back to the standard proxy resolver of the operating system.
See SystemProxyResolver::for_url for more information about how the proxy is resolved.