# ip-set

> Efficient mutable set for IP addresses

Latest version **3.0.0** (published 2025-02-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install ip-set
pnpm add ip-set
yarn add ip-set
bun add ip-set
```

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2025-02-25 |
| First published | 2014-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 1 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 34 |
| Author | Travis Fischer |
| Maintainers | feross, mafintosh, flet, watson, diegorbaquero, hicom150, jhiesey, webtorrent-bot, alxhotel, fisch0920 |
| Keywords | IP, address, ipv4, ipv6, set, blacklist, blocklist |

## Links

- npm: https://www.npmjs.com/package/ip-set
- Repository: https://github.com/fisch0920/ip-set
- Homepage: http://webtorrent.io
- Issues: https://github.com/fisch0920/ip-set/issues
- npm.io page: https://npm.io/package/ip-set

## Dependencies (1)

- [ip-address](https://npm.io/package/ip-address.md) ^10.0.1

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2025-02-25
- 2.2.0 — 2024-10-16
- 2.1.0 — 2020-11-17
- 2.0.1 — 2020-11-17
- 2.0.0 — 2020-11-17
- 1.0.2 — 2019-05-09
- 1.0.1 — 2016-08-08
- 1.0.0 — 2014-07-29

## README

# ip-set

<p align="center">
  <a href="https://github.com/transitive-bullshit/ip-set/actions/workflows/main.yml"><img alt="Build Status" src="https://github.com/transitive-bullshit/ip-set/actions/workflows/main.yml/badge.svg" /></a>
  <a href="https://www.npmjs.com/package/ip-set"><img alt="NPM" src="https://img.shields.io/npm/v/ip-set.svg" /></a>
  <a href="https://github.com/transitive-bullshit/ip-set/main/LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue" /></a>
</p>

## 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](http://browserify.org/)! This module is used by [WebTorrent](http://webtorrent.io).

## Install

```
npm install ip-set
```

## Usage

```js
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

```js
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)

- [x] Port IPv4 implementation from `torrent-stream`
- [x] Add basic tests
- [x] Support CIDR notation
- [ ] Support IPv6
- [ ] Investigate potential use of [node-iptrie](https://github.com/postwait/node-iptrie)

## Credits

Original interval-tree written by [galedric](https://github.com/galedric) for [torrent-stream](https://github.com/mafintosh/torrent-stream). Ported to an isolated npm module by [transitive-bullshit](https://github.com/transitive-bullshit) for [webtorrent](http://webtorrent.io).

## License

MIT. Copyright (c) Travis Fischer

Support my OSS work by <a href="https://twitter.com/transitive_bs">following me on twitter <img src="https://storage.googleapis.com/saasify-assets/twitter-logo.svg" alt="twitter" height="24px" align="center"></a>

---
_Source: https://npm.io/package/ip-set · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
