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.
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. Performs a blocking DNS lookup.
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. Performs a blocking DNS lookup.
myIpAddress()Returns an IP address of the machine running the PAC. Which address you get is engine-specific.
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.
myIpAddressEx()Microsoft IPv6 extension. Semicolon-separated list of the machine's addresses.
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 | pacparser | reference |
|---|---|---|---|---|---|---|---|
isPlainHostName | yes | yes | yes | yes | yes | yes | yes |
dnsDomainIs | yes | yes | yes | yes | yes | yes | yes |
localHostOrDomainIs | yes | yes | yes | yes | yes | yes | yes |
isResolvable | yes | yes | yes | yes | yes | yes | yes |
isInNet | yes | yes | yes | yes | yes | yes | yes |
dnsResolve | yes | yes | yes | yes | yes | yes | yes |
myIpAddress | yes | yes | yes | yes | yes | yes | yes |
dnsDomainLevels | yes | yes | yes | yes | yes | yes | yes |
shExpMatch | yes | yes | yes | yes | yes | yes | yes |
weekdayRange | yes | yes | yes | yes | yes | yes | yes |
dateRange | yes | yes | yes | yes | yes | yes | yes |
timeRange | yes | yes | yes | yes | yes | yes | yes |
alert | yes | yes | yes | no | no | yes | yes |
dnsResolveEx | yes | yes | no | yes | yes | yes | no |
myIpAddressEx | yes | yes | no | yes | yes | yes | no |
isResolvableEx | yes | yes | no | yes | yes | yes | no |
isInNetEx | yes | yes | no | yes | yes | yes | no |
sortIpAddressList | yes | yes | no | no | no | no | no |