load-ip-set

    2.2.1 • Public • Published

    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.

    const loadIPSet = require('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.

    Install

    npm i load-ip-set

    DownloadsWeekly Downloads

    4,352

    Version

    2.2.1

    License

    MIT

    Unpacked Size

    6.08 kB

    Total Files

    4

    Last publish

    Collaborators

    • alxhotel
    • feross
    • mafintosh
    • flet
    • watson
    • diegorbaquero
    • hicom150
    • jhiesey
    • webtorrent-bot