Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 676 Bytes

README.md

File metadata and controls

34 lines (22 loc) · 676 Bytes

@chainsafe/netmask

Typescript implementation for using CIDR masks for address filtering. Heavily inspired by go implementation.

Features

How to use

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")

Quick start

  1. yarn
  2. yarn run build
  3. yarn run test