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 (a blocking DNS lookup), so guard the call with an
IP-literal test such as /^\d+\.\d+\.\d+\.\d+$/.test(host) if you only want to match literal IPs.
Example
if (/^\d+\.\d+\.\d+\.\d+$/.test(host) &&
isInNet(host, "10.0.0.0", "255.0.0.0")) {
return "DIRECT";
}
Engine notes
| Engine | Behaviour | Source |
|---|---|---|
| chromium | Validates pattern and mask; a non-literal first argument is resolved with dnsResolve and null gives false. | code, verified 2026-10-04 |
| firefox | Same logic as Chromium (validates pattern and mask, resolves names). | code, verified 2026-10-04 |
| pacparser | Does not validate pattern or mask: isInNet(ip, net, "255.255.0") is true where Chromium and Firefox return false. | code, verified 2026-10-04 |
Availability
| Function | chromium | chromium | firefox | pacparser | pacparser | pacparser | reference |
|---|---|---|---|---|---|---|---|
isInNet | yes | yes | yes | yes | yes | yes | yes |