Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ip-set

fisch092036.1kMIT3.0.0

Efficient mutable set for IP addresses

IP, address, ipv4, ipv6, set, blacklist, blocklist

readme

ip-set

Build Status NPM MIT License

Intro

Efficient mutable set data structure optimized for use with IPv4 and IPv6 addresses. The primary use case is for working with potentially large IP blacklists.

Works in the browser with browserify! This module is used by WebTorrent.

Install

npm install ip-set

Usage

const IPSet = require('ip-set')

const ipSet =
  new IPSet(/* optionally pass an array of IP addresses to seed the set with */)
ipSet.add(exampleBlockedIP1)
ipSet.add(exampleBlockedIP2)
let isBlocked = ipSet.contains(exampleBlockedIP2) // isBlocked will be true

CIDR ip's are also supported

ipSet.add(`192.168.1.0/24`)
let isBlockedInList = ipSet.contains('192.168.1.0') // isBlockedInList will be true
isBlockedInList = ipSet.contains('192.168.1.255') // isBlockedInList will be true

Todo

(prioritized highest to lowest)

  • <input checked="" disabled="" type="checkbox"> Port IPv4 implementation from torrent-stream
  • <input checked="" disabled="" type="checkbox"> Add basic tests
  • <input checked="" disabled="" type="checkbox"> Support CIDR notation
  • <input disabled="" type="checkbox"> Support IPv6
  • <input disabled="" type="checkbox"> Investigate potential use of node-iptrie

Credits

Original interval-tree written by galedric for torrent-stream. Ported to an isolated npm module by transitive-bullshit for webtorrent.

License

MIT. Copyright (c) Travis Fischer

Support my OSS work by following me on twitter twitter