Skip to main content

Module parse

Module parse 

Source
Expand description

Pure parsers for OS proxy string formats.

List parsers drop malformed elements and keep the rest. Dropping a scheme endpoint without recording it would be fail-open; bypass drops are fail-closed → rejected.

§Writing a bypass list

Every store has one, no two of them read it the same way, and the differences decide which hosts go direct. What an entry means to this crate, by the list it is written in — the store’s own reading, except where a cell says the two part company:

Entryno_proxy, KDE NoProxyForWindows ProxyOverridemacOS ExceptionsListGNOME ignore-hosts
separator between entries, alone — a ; leaves the two names one dead rule, and an entry still holding a space is rejected;, , or whitespacethe array is the separatorthe array is the separator
example.comthat host and everything under itthat host alonethat host alonethat host and everything under it
.example.com, *.example.comthe subdomains, not example.com itself*.example.com is the subdomains; .example.com is rejected — Windows has no reading for a leading . (below)the subdomainsthe same rule as the bare name: the domain and its subdomains
a * anywhere else (192.168.*)a glob here, which is Chromium’s reading; Go and libproxy take it as literal text no host carriesa globsyntax only as a trailing .*, which misses the bare host a Mac’s own name.* still reaches; anything else is rejectednever syntax; rejected
a bare *every destination directevery destination directrejected — it matches no host on a Macrejected, same reason
10.0.0.0/8the networkrejected — Windows has no / in this grammar, and one entry holding it turns the proxy off for every destination (below); write the range as 10.*the networkthe network
example.com:8080holds the entry to that portholds itrejected — macOS compares the whole entry to the host name, so a port kills itholds it, but a portless http:// URL is asked about with port 0 and will not meet it
<local>, <-loopback>readreadreadread
a space at either endtrimmedtrimmedkept, and no host carries it, so the entry is rejectedtrailing trimmed, leading kept and rejected

A rejected entry is not dropped in silence: it lands in BypassRules::rejected with the reason, so a rule that does nothing reads as doing nothing rather than as live.

Two spellings cost a Windows list more than themselves, and both are refused here rather than read. An entry starting with . is granted nothing by any reader measured: WinINet refuses the whole list over one, while WinHTTP and the registry reading keep the list and send the subdomains to the proxy regardless — *.name is the spelling to write. An entry holding a /, a CIDR block included, goes further still: the registry reading stops using the proxy at all and every destination goes direct. Both land in rejected with the reason while the entries beside them stay live — which is narrower than what the machine does with the same list, and as wide a claim as the readings support.

Two rows are worth stating flat. A bare name changes meaning between the first column and the next two, so contoso.com in no_proxy covers api.contoso.com and the same text in ProxyOverride does not. And <local> / <-loopback> are read out of every list here so the sources share one vocabulary, while only Windows’ own resolver acts on them: a macOS or GNOME store spelling one gets a bypass from this crate and none from the machine. the_local_token_bypasses_nothing_here in tests/mac_exceptions_list.rs measures the macOS half; GNOME’s is read off GLib, in src/sys/linux/gsettings_map.rs.

Constants§

WINDOWS_DEFAULT_PORT
The port assumed when a Windows ProxyServer entry omits one.

Functions§

no_proxy
Parse no_proxy into BypassRules: *, CIDR, domains, :port, and a localhost bypass that stays on unless an entry clears it. Entries are separated by , alone — not whitespace and not ;, which is what Go’s httpproxy does and what KDE’s readers do with NoProxyFor. Malformed → BypassRules::rejected. An entry that repeats one already in BypassRules::patterns is dropped, first spelling kept, so the list can be shorter than the string had entries.
proxy_override
Parse a Windows ProxyOverride registry value into BypassRules.
proxy_server
Parse Windows ProxyServer (WINHTTP_CURRENT_USER_IE_PROXY_CONFIG).
windows_manual
Assemble a ProxyMode::Manual from the two Windows registry strings.