3.0.1 • Published 1 year ago

load-ip-set v3.0.1

Weekly downloads
2,762
License
MIT
Repository
github
Last release
1 year ago

load-ip-set ci npm downloads javascript style guide

download and parse ip-set (blocklist) files

This module is used by WebTorrent!

Install

npm install load-ip-set

Usage

Given one of the following:

  • http/https url (gzip, deflate, or no compression)
  • filesystem path (gzip, or no compression)
  • array of ip addresses or { start: '1.2.3.0', end: '1.2.3.255' } ip ranges

this module loads the ip set (downloading from the network, if necessary) and returns an ip-set object. An ip-set is just a mutable set data structure optimized for use with IPv4 and IPv6 addresses.

import loadIPSet from 'load-ip-set'
loadIPSet('http://example.com/list.txt', (err, ipSet) => {
  if (err) throw err
  ipSet.contains('1.2.3.4') //=> true
  ipSet.contains('2.2.2.2') //=> false
})

The second argument can be an optional opts object which will be passed to simple-get and the node.js core http.request method. This is useful for setting the user agent, for example.

loadIPSet('http://example.com/list.txt', {
  headers: {
    'user-agent': 'WebTorrent (http://webtorrent.io)'
  }
}, (err, ipSet) => {

})

License

MIT. Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC.

3.0.1

1 year ago

3.0.0

1 year ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.2

3 years ago

2.1.1

4 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.3.1

7 years ago

1.3.0

8 years ago

1.2.7

8 years ago

1.2.6

8 years ago

1.2.5

8 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.6

9 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago