Skip to main content

createSubnetChecker

@webda/core


Function: createSubnetChecker()

createSubnetChecker(cidrs): (ip) => boolean

Defined in: packages/core/src/services/subnetchecker.ts:13

Create a matcher for a list of CIDRs

A bare IP address is read as a single address network: /32 for IPv4, /128 for IPv6. IPv4-mapped IPv6 addresses (::ffff:10.0.0.1, as reported by dual-stack Node sockets) match the IPv4 networks. A value that is not an IP address (or is undefined) is never in the networks: the checker does not throw.

Parameters​

cidrs​

string[]

the CIDRs or IP addresses

Returns​

a function telling if an IP address belongs to one of the networks

(ip) => boolean