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-boa to run. Bypass lists do not apply.

Structs§

BoaEvaluatorpac-boa
PacEvaluator on boa_engine. Prefers FindProxyForURL; FindProxyForURLEx only if it is the sole entry point (Ex-only hostfns are not registered).
PacPolicy
Safety envelope for PAC evaluation (pac-boa; ignored by WinHttpPacResolver).
PacScript
PAC script body (newtype so “this is JS that will run” stays visible in signatures).
WinHttpPacResolverWindows and pac-windows-native
PAC/WPAD via WinHttpGetProxyForUrlEx. Reuse one session; the cache it does not bound is described on resolve.

Enums§

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_LOOP_LIMIT
The default loop-iteration cap (10M). Hitting it aborts with Error::PacEvaluation. Unlike the two constants below this one is not boa_engine’s default: RuntimeLimits::default() leaves loop_iteration at u64::MAX, so an unbounded while is left to the timeout — which releases the caller without stopping the script (see PacPolicy::with_timeout).
DEFAULT_PAC_RECURSION_LIMIT
The default function-call recursion depth (512) — boa_engine’s own default, kept so stating it is not a behaviour change. Tighten with PacPolicy::with_recursion_limit.
DEFAULT_PAC_STACK_SIZE_LIMIT
The default engine value-stack length (10 240) — also boa_engine’s own default. Entry count, not bytes or OS stack size — in particular not the native stack the parser recurses on, which PacPolicy cannot bound at all.
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.

Traits§

PacEvaluator
macOS may wrap CFNetworkCopyProxiesForAutoConfigurationScript. PacPolicy on the impl.

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+fragment; path+query only for https/wss. Not a PacPolicy knob. Custom PacEvaluator impls should still sanitize.