netio/proxy.rs#
Source: lib/netio/proxy.rs
proxy -- which HTTP proxy a request goes through (Client::with_proxy)
Proxy::new("http://user:pw@proxy.lan:3128") one proxy for http and https
Proxy::none().http(..).https(..) a proxy per scheme (Endpoint::parse)
proxy.no_proxy("localhost, .corp.example, 10.0.0.0/8")
Proxy::from_env() http_proxy (lower case only), https_proxy / HTTPS_PROXY, all_proxy /
ALL_PROXY, no_proxy / NO_PROXY -- as curl reads them: HTTP_PROXY in
upper case is left alone, since a CGI program gets the request's
"Proxy:" header as that variable (httpoxy, CVE-2016-5385 and others)
proxy.for_url(&url) -> Option<&Endpoint>
http:// goes to the proxy as an absolute-form request (RFC 9112 3.2.2); https:// through a
CONNECT tunnel (RFC 9110 9.3.6), in which TLS checks the server itself, not the proxy. Only
plain-HTTP proxies: an https:// or socks proxy URL is refused (None). Loopback addresses and
localhost never go through a proxy (as Go's net/http): a local service is not sent elsewhere.
NO_PROXY: "*" for all, names (a leading "." or "*." optional) for themselves and the names
below them, IP addresses and CIDR ranges for URLs that name an address (no lookup); an entry
may end in ":port".
struct Endpointa proxy server: where to connect and the credentials it gets (Basic)host: Stringport: u16
impl Endpoint
fn parse(s: &str) -> Option<Endpoint>"http://[user[:password]@]host[:port][/]" or "host[:port]" (http assumed); the port defaults to 80. None for another scheme (https://, socks5://), a path, or a bad hostfn with_auth(mut self, user: &str, password: &str) -> Endpointwith these credentials (Basic: "user:password" in base64)fn url(&self) -> Urlthe proxy as a URL of its own (where the client connects)fn key(&self) -> String"host:port"struct Proxythe proxies of a client: one per scheme, and the hosts that go direct
impl Proxy
fn none() -> Proxyno proxy (to add them one by one)fn new(url: &str) -> Option<Proxy>one proxy for http and https (Endpoint::parse) -> None when it is not onefn http(mut self, e: Endpoint) -> Proxythe proxy for http:// URLsfn https(mut self, e: Endpoint) -> Proxythe proxy for https:// URLs (a CONNECT tunnel)fn no_proxy(mut self, list: &str) -> Proxyhosts that go direct: a comma-separated list as NO_PROXY writes it (entries that are not one are left out)fn from_env() -> Option<Proxy>the proxies the environment names (see the module header); None when it names nonefn from_vars(get: &dyn Fn(&str) -> Option<String>) -> Option<Proxy>from_env with the variables fromget(tests, or a configuration of the app's own)fn bypass(&self, url: &Url) -> boolwhether a URL goes direct: loopback, localhost, or an entry of no_proxyfn for_url(&self, url: &Url) -> Option<&Endpoint>the proxy a request tourlgoes through (None: direct)