isInNet()
True if the IP address of host is in the network pattern/mask. Resolves host via DNS if it is not an IP literal.
isInNet(host, pattern, mask) → booleanPattern and mask are dotted IPv4 strings: isInNet(host, "10.0.0.0", "255.0.0.0"). When host
is a name, the engine first resolves it and the script waits for the answer. Only the first call
for a name sends a DNS query; repeats are answered from a cache, so ten calls for one name are not
ten queries. The cost comes from different names and from a DNS server that does not answer (see
DNS in PAC files). When host is already an IP address, nothing is
looked up. Guard the call with an IP-address test such as /^\d+\.\d+\.\d+\.\d+$/.test(host) if
you only want to match addresses written in the URL.
The engines agree only as long as the pattern and the mask are written as four decimal numbers. With a CIDR pattern, a short mask, leading zeros or a missing argument, pactester, the browsers and Windows give different answers, as the section below explains.
Example
if (/^\d+\.\d+\.\d+\.\d+$/.test(host) &&
isInNet(host, "10.0.0.0", "255.0.0.0")) {
return "DIRECT";
}
pactester and the browsers can disagree about isInNet
For a plain call such asisInNet(host, "10.0.0.0", "255.0.0.0") every engine agrees. With a
network in CIDR form ("10.0.0.0/8"), a shortened or prefix-length mask, leading zeros, a
missing argument or an upper-case host name, pactester (pacparser), Chrome and Edge, Firefox
and Windows (WinHTTP) do not all return the same answer. A file that passes a pactester test
can then send the internal network to the proxy in the browser. Write the network and the mask
as four plain numbers each. Paste your file into the PAC file tester and switch between the Chromium, Firefox and pacparser profiles to see which answer each engine gives. The tester also flags the calls where the engines disagree.Check how your own file behaves with the PAC file tester: switch the engine profile between Chromium, Firefox, pacparser and Windows and compare the trace. All engine differences are collected in pactester vs Chrome and Firefox.
Engine notes
| Engine | Behaviour | Source |
|---|---|---|
| chromium | Validates pattern and mask; a non-literal first argument is resolved with dnsResolve and null gives false. | lab, verified 2026-10-11 |
| firefox | Same logic as Chromium (validates pattern and mask, resolves names); upper-case names resolve. | lab, verified 2026-10-11 |
| pacparser | Keeps the original Netscape helper without a check of pattern and mask, so some invalid calls are true where Chromium and Firefox return false. | lab, verified 2026-10-11 |
| chromium | An IPv4 address as first argument is compared without a lookup. A name is resolved with dnsResolve, so a repeat of the same name in one request is answered from the table of names already resolved, and after 20 different names isInNet returns false without asking. | code, verified 2026-10-14 |
| firefox | An IPv4 address as first argument is compared without a lookup. A name goes to the browser's DNS cache on every call; there is no table in the PAC engine. | code, verified 2026-10-14 |
| winhttp | 100 calls for one name in one run sent one DNS query; the Windows DNS cache answered the rest. When the DNS server does not answer, every call waits about 12 s again. | lab, verified 2026-10-14 |
| winhttp | Resolves host names (upper case too) and compares IPv4 only; "LOCALHOST" is in 127.0.0.0/8. No check of pattern or mask: a CIDR pattern gives false, a short mask or a prefix length such as "8" can give true, and leading zeros are read as octal. A failed lookup counts as 0.0.0.0, so isInNet(dnsResolve("nonexistent.invalid"), "0.0.0.0", "255.255.255.255") is true. A missing or extra argument raises an error. | lab, verified 2026-10-11 |
Availability
| Function | chromium | chromium | firefox | pacparser | pacparser | winhttp | wininet | reference |
|---|---|---|---|---|---|---|---|---|
isInNet | yes | yes | yes | yes | yes | yes | yes | yes |
Related rules
- DNS function on the path of every request PAC-P001
- isInNet called with an invalid address, mask or argument count PAC-E010
- RFC 1918 range with the wrong mask PAC-C007
- isInNet arguments in the wrong order PAC-C016
- isInNet called with an IPv6 address PAC-K014
- isInNet called with a hostname PAC-P002
Frequently asked questions
Can I use CIDR notation such as 10.0.0.0/8 in isInNet?
No. isInNet expects the network and the mask as four numbers each, isInNet(host, "10.0.0.0", "255.0.0.0"). With "10.0.0.0/8" Chrome, Edge and Firefox return false, while pactester can return true, so a pactester test does not catch the mistake. The tester at findproxyforurl.net/check/ flags it.
Why does isInNet return true in pactester but false in Chrome?
pactester uses pacparser, whose helper functions differ from those in Chrome and Firefox for unusual arguments such as a CIDR network or a short mask. Test the file in a browser engine profile as well, for example in the tester at findproxyforurl.net/check/.