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)  →  boolean

Pattern 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

EngineBehaviourSource
chromiumValidates pattern and mask; a non-literal first argument is resolved with dnsResolve and null gives false.code, verified 2026-10-04
services/proxy_resolver/pac_js_library.h@cb6eb0e7
firefoxSame logic as Chromium (validates pattern and mask, resolves names).code, verified 2026-10-04
netwerk/base/ascii_pac_utils.js@3f73c528
pacparserDoes not validate pattern or mask: isInNet(ip, net, "255.255.0") is true where Chromium and Firefox return false.code, verified 2026-10-04
src/pac_utils.h@v1.5.3

Availability

Derived from each engine's vendored helper library plus its native bindings (see engines).
Functionchromium
<=51
chromium
>=52
firefox
all
pacparser
<=1.4.6
pacparser
1.5.0
pacparser
>=1.5.1
reference
all
isInNetyesyesyesyesyesyesyes

Related rules