pub fn proxy_override(spec: &str) -> BypassRulesExpand description
Parse a Windows ProxyOverride registry value into BypassRules.
Like no_proxy, but entries are separated by ;, , or whitespace, as WinHTTP
documents, and a bare name matches that name alone rather than the domain under
it: contoso.com here does not bypass api.contoso.com. Write *.contoso.com for
the subdomains, which is also what Windows asks for — .contoso.com is rejected rather
than read, because no measured reader grants it. A CIDR entry is rejected too, because
Windows answers a / with the whole list: write the range as the wildcard Windows does
read, 10.*. <local> →
HostPattern::Local and <-loopback> (IE9+) →
HostPattern::SubtractImplicit are read by
no_proxy as well as by this one, the
way Chromium reads them (“we allow it on all platforms and interpret it the same way”,
proxy_host_matching_rules.cc:113). Malformed entries skipped into
BypassRules::rejected.
The bare-name rule is measured, not inherited: WinINet and WinHTTP were each handed a
bypass list and a destination and asked where they connected. Both reimplementations
this crate reads alongside — Chromium and libproxy — answer the question, and they
answer it differently, so neither could settle it. The readings are the rows of
a_bare_name_in_a_windows_list_is_the_one_host in tests/bypass.rs.
let rules = parse::proxy_override("<local>;*.contoso.com;<-loopback>");
assert!(rules.excludes_simple_hostnames());
assert!(!rules.bypass_loopback());
assert!(rules.matches_authority("www.contoso.com"));
// Whitespace separates too, so this is two rules and not one dead one.
let rules = parse::proxy_override("*.contoso.com intranet");
assert!(rules.matches_authority("www.contoso.com"));
assert!(rules.matches_authority("intranet"));
// A bare name is the host itself. The same text in `no_proxy` takes the subdomains.
let rules = parse::proxy_override("contoso.com");
assert!(rules.matches_authority("contoso.com"));
assert!(!rules.matches_authority("api.contoso.com"));
assert!(parse::no_proxy("contoso.com").matches_authority("api.contoso.com"));
// A `/` is recorded, not read. `no_proxy` takes the same text as a mask.
let rules = parse::proxy_override("10.0.0.0/8");
assert!(!rules.matches_authority("10.1.2.3"));
assert_eq!(rules.rejected.len(), 1);
assert!(parse::no_proxy("10.0.0.0/8").matches_authority("10.1.2.3"));