Typescript implementation for using CIDR masks for address filtering. Heavily inspired by go implementation.
- IPv4 and IPv6 support
- Typescript support
npm i -s @chainsafe/netmask
or
yarn add @chainsafe/netmask
Example usage:
import {IpNet} from "@chainsafe/netmask"
new IpNet("192.168.0.1/24").contains("192.168.0.16")
new IpNet("192.168.0.1", "24").contains("192.168.0.16")
new IpNet("2001:db8::/128").contains("2001:db8::")
new IpNet("192.168.0.1", "255.255.255.0").contains("192.168.0.16")
yarn
yarn run build
yarn run test