Socket
Socket
Sign inDemoInstall

@ofarukcaki/ip-range

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ofarukcaki/ip-range

Check if the given IP address is in the provided range.


Version published
Weekly downloads
7
decreased by-30%
Maintainers
1
Install size
16.0 kB
Created
Weekly downloads
 

Readme

Source

ip-range

Check if the given IP address is in the provided range.

Install

npm i @ofarukcaki/ip-range

Usage

const Iprange = require('@ofarukcaki/ip-range').default;

const initialRanges = [
  ['0.0.0.1', '0.0.0.255'],
  ['123.123.0.0', '123.123.124.255'],
  ['66.0.0.0', '66.1.0.0'],
];

/* Initialize a new range by providing an array of string arrays
 * consists of start-end addresses of an IP.
 * Don't pass a parameter if you don't want to initialize on creation
 */
const range = new Iprange(initialRanges);

// add a new range
const newRange = ['192.0.0.1', '192.0.0.5'];
range.addRange(newRange);

console.log(range.checkIP('123.123.1.0')); // true

console.log(range.checkIP('66.0.1.255')); // true

console.log(range.checkIP('192.0.0.0')); // false

Keywords

FAQs

Last updated on 26 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc