Skip to main content

Module pac

Module pac 

Source
Available on crate feature pac only.
Expand description

PAC evaluation (pac feature, off by default): script → Vec<ProxyStep> like resolve.

No in-crate fetch: pass body to evaluate. Untrusted code: PacPolicy defaults block DNS, fake local IP, 5 s budget. pac-quickjs to run. Bypass lists do not apply.

Structs§

PacPolicy
Safety envelope for PAC evaluation (pac-quickjs and pac-subprocess; ignored by the native resolvers, which hand the script to the OS).
PacResolver
Routes a whole ProxyConfig to whichever PAC engine answers its mode.
PacScript
PAC script body (newtype so “this is JS that will run” stays visible in signatures).
SubprocessEvaluatorpac-subprocess
PacEvaluator that runs each evaluation in a fresh worker process and kills it at the deadline.
WinHttpPacResolverWindows and pac-windows-native
PAC/WPAD via WinHttpGetProxyForUrlEx. Reuse one session; the cache it does not bound is described on resolve.

Enums§

AutoProxyResetWindows and pac-windows-native
What WinHttpPacResolver::reset_auto_proxy did.
PacRequirement
What requirement says a ProxyMode needs before routing.
WinHttpPacSourceWindows and pac-windows-native
Where WinHTTP looks for the PAC script (WINHTTP_AUTOPROXY_OPTIONS, not a body).

Constants§

DEFAULT_PAC_TIMEOUT
The default evaluation timeout, five seconds.
DEFAULT_WINHTTP_PAC_TIMEOUTWindows and pac-windows-native
Default native resolution budget (5 s): same as DEFAULT_PAC_TIMEOUT, but also covers WPAD discovery and script download.
QUICKJS_AVAILABLE
Whether this build carries QuickJS, so that evaluate runs a script rather than answering Error::PacEngineUnavailable: pac-quickjs on a target other than Android and iOS. Lets a caller pick an engine before calling, without its own cfg.

Traits§

PacEvaluator
A replaceable engine that evaluates a PAC script for one URL.

Functions§

evaluate
Evaluate script for url under policy (sanitize_url first).
evaluate_with_host
Like evaluate, but the caller chooses host (url is still sanitized).
parse_find_proxy_result
Parse a FindProxyForURL return string into an ordered fallback chain.
requirement
What mode needs before evaluate can be called for it.
sanitize_url
Chromium SanitizeUrl: strip userinfo and fragment always, and path and query only for https/wss. Not a PacPolicy knob. Custom PacEvaluator impls should still sanitize.

Type Aliases§

NativePacResolverWindows and pac-windows-native
The native PAC resolver this target has: WinHttpPacResolver on Windows, CfNetworkPacResolver on macOS and iOS, AndroidPacResolver on Android, whichever the matching pac-*-native feature (or pac-native) compiled in.