A cross-platform Rust library and CLI for resolving the proxy that should be used for a URL. It supports environment variables, operating system proxy settings, PAC files, and normalized proxy result parsing.
- Cross-platform system proxy detection
- macOS: SystemConfiguration/CoreFoundation manual proxy and PAC settings
- Windows: WinHTTP/IE proxy config, manual proxy lists, bypass rules, WPAD
- Linux: GNOME
gsettingsand KDEkreadconfig5/kreadconfig6
- PAC support
- Downloads
http://andhttps://PAC files - Loads
file://and local PAC files - Executes
FindProxyForURLwithboa_engine - Implements common PAC helpers such as
dnsResolve,myIpAddress,isInNet,shExpMatch,dnsDomainIs,localHostOrDomainIs,dnsDomainLevels, andweekdayRange
- Downloads
- Proxy parsing and post-processing
- Normalizes manual and PAC proxy results to full URLs
- Deduplicates proxy entries
- Supports protocol filtering and maximum result limits
- Converts
SOCKS/SOCKS5PAC directives tosocks5:// - Preserves
DIRECTfallback semantics
- Priority order: environment variables -> system proxy/PAC ->
DIRECT
Latest local validation:
| Check | Result | Notes |
|---|---|---|
cargo fmt --check |
PASS | Rust formatting is clean |
cargo test |
PASS | 9 unit tests + 1 doctest passed |
cargo package --allow-dirty |
PASS | Crate packages and verifies successfully |
| Open-marker scan | PASS | No open implementation markers remain in source/config files |
The repository CI runs the same Rust checks natively on Ubuntu, macOS, and Windows through GitHub Actions, so platform-specific system proxy modules are validated on their own operating systems instead of relying on fragile local cross-compilation.
cargo install proxyparserOr build from source:
git clone https://github.com/zongyangbigpolo/rustproxyparser.git
cd rustproxyparser
cargo build --release# Query the proxy for a specific URL
proxyparser https://httpbin.org/ip
# Use the default target (https://www.google.com)
proxyparserOutput is either DIRECT or a normalized proxy list, for example:
Proxy for https://example.com -> http://proxy.local:8080; socks5://backup.local:1080; DIRECT
use proxyparser::find_proxy_for_url;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let proxy = find_proxy_for_url("https://example.com")?;
println!("{proxy}");
Ok(())
}Proxy parser APIs are also public:
use proxyparser::proxy::{parse_proxy_result, ProxyParseOptions, ProxyScheme};
let options = ProxyParseOptions {
allowed_schemes: Some(vec![ProxyScheme::Http, ProxyScheme::Socks5]),
include_direct: true,
max_proxies: 4,
};
let parsed = parse_proxy_result(
"PROXY proxy.local:8080; SOCKS socks.local:1080; DIRECT",
&options,
);
assert_eq!(
parsed.to_proxy_string(),
"http://proxy.local:8080; socks5://socks.local:1080; DIRECT"
);This project is licensed under the MIT License.