PAC function reference
The functions a PAC file can call, what they really do, and which engines provide them. Availability is derived from the engines' own helper libraries, not from documentation.
Every PAC file defines one function itself, FindProxyForURL(url, host). The functions below are the helpers it can call.
Standard (Netscape) functions
isPlainHostName(host)True if the host name contains no domain part (no dot), e.g. "intranet".
dnsDomainIs(host, domain)True if host ends with domain. A plain string suffix comparison, no DNS lookup.
localHostOrDomainIs(host, hostdom)True if host equals hostdom exactly, or host is the unqualified first label of hostdom.
isResolvable(host)True if the host name resolves in DNS. The script waits for the resolver, which usually answers from a cache.
isInNet(host, pattern, mask)True if the IP address of host is in the network pattern/mask. Resolves host via DNS if it is not an IP literal.
dnsResolve(host)Resolves a host name to an IP address string, or null when the name does not resolve (false in Windows). The script waits for the answer; repeats for the same name come from a cache.
myIpAddress()Returns one IP address of the computer that runs the PAC file. Which one depends on the engine, the routes and the adapter settings, so it is not guaranteed to be the address your PAC logic expects.
dnsDomainLevels(host)Number of dots in the host name ("www.corp.example" gives 2).
shExpMatch(str, pattern)Shell-glob match of str against pattern; * matches any sequence, ? one character. The whole string must match.
weekdayRange(wd1 [, wd2] [, "GMT"])True on the given weekday or within the weekday range (SUN, MON, ... SAT). Local time unless "GMT" is passed.
dateRange(day | month | year ... [, "GMT"])True if the current date is within the given day, month and/or year range.
timeRange(hour | hour, min | hour, min, sec ... [, "GMT"])True if the current time is within the given hour/minute/second range.
Microsoft IPv6 extensions (*Ex)
dnsResolveEx(host)Microsoft IPv6 extension. Returns a semicolon-separated list of IPv4 and IPv6 addresses, or an empty string (false in Windows).
myIpAddressEx()Microsoft IPv6 extension. Semicolon-separated list of the computer's addresses; which addresses and in which order depends on the engine.
isResolvableEx(host)Microsoft IPv6 extension. True if the host resolves to any IPv4 or IPv6 address.
isInNetEx(ip, prefix)Microsoft IPv6 extension. True if ip is inside the CIDR prefix, e.g. isInNetEx(ip, "2001:db8::/32").
sortIpAddressList(list)Microsoft IPv6 extension. Sorts a semicolon-separated IP address list.
Debugging
alert(message)Debug output from a PAC. Where it goes depends on the engine; remove it from production files.
Availability by engine
| Function | chromium | chromium | firefox | pacparser | pacparser | winhttp | wininet | reference |
|---|---|---|---|---|---|---|---|---|
isPlainHostName | yes | yes | yes | yes | yes | yes | yes | yes |
dnsDomainIs | yes | yes | yes | yes | yes | yes | yes | yes |
localHostOrDomainIs | yes | yes | yes | yes | yes | yes | yes | yes |
isResolvable | yes | yes | yes | yes | yes | yes | yes | yes |
isInNet | yes | yes | yes | yes | yes | yes | yes | yes |
dnsResolve | yes | yes | yes | yes | yes | yes | yes | yes |
myIpAddress | yes | yes | yes | yes | yes | yes | yes | yes |
dnsDomainLevels | yes | yes | yes | yes | yes | yes | yes | yes |
shExpMatch | yes | yes | yes | yes | yes | yes | yes | yes |
weekdayRange | yes | yes | yes | yes | yes | yes | yes | yes |
dateRange | yes | yes | yes | yes | yes | yes | yes | yes |
timeRange | yes | yes | yes | yes | yes | yes | yes | yes |
alert | yes | yes | yes | no | yes | yes | yes | yes |
dnsResolveEx | yes | yes | no | yes | yes | yes | yes | no |
myIpAddressEx | yes | yes | no | yes | yes | yes | yes | no |
isResolvableEx | yes | yes | no | yes | yes | yes | yes | no |
isInNetEx | yes | yes | no | yes | yes | yes | yes | no |
sortIpAddressList | yes | yes | no | no | no | yes | yes | no |
Last updated: