Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

netmask

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netmask - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

CHANGELOG.md

40

lib/netmask.js

@@ -34,6 +34,26 @@ // Generated by CoffeeScript 1.12.7

}
while (b.length < 4) {
b.unshift(0);
switch (b.length) {
case 1:
if (b[0] > 0xFFFFFFFF) {
throw new Error('Invalid IP');
}
return b[0] >>> 0;
case 2:
if (b[0] > 0xFF || b[1] > 0xFFFFFF) {
throw new Error('Invalid IP');
}
return (b[0] << 24 | b[1]) >>> 0;
case 3:
if (b[0] > 0xFF || b[1] > 0xFF || b[2] > 0xFFFF) {
throw new Error('Invalid IP');
}
return (b[0] << 24 | b[1] << 16 | b[2]) >>> 0;
case 4:
if (b[0] > 0xFF || b[1] > 0xFF || b[2] > 0xFF || b[3] > 0xFF) {
throw new Error('Invalid IP');
}
return (b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3]) >>> 0;
default:
throw new Error('Invalid IP');
}
return (b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3]) >>> 0;
};

@@ -61,3 +81,3 @@

base = 16;
} else if ('0' <= s[i + 1] && s[i + 1] <= '7') {
} else if ('0' <= s[i + 1] && s[i + 1] <= '9') {
i++;

@@ -69,10 +89,10 @@ base = 8;

start = i;
while (s.length > 0) {
while (i < s.length) {
if ('0' <= s[i] && s[i] <= dmax) {
n = n * base + (chr(s[i]) - chr0);
n = (n * base + (chr(s[i]) - chr0)) >>> 0;
} else if (base === 16) {
if ('a' <= s[i] && s[i] <= 'f') {
n = n * base + (10 + chr(s[i]) - chra);
n = (n * base + (10 + chr(s[i]) - chra)) >>> 0;
} else if ('A' <= s[i] && s[i] <= 'F') {
n = n * base + (10 + chr(s[i]) - chrA);
n = (n * base + (10 + chr(s[i]) - chrA)) >>> 0;
} else {

@@ -84,4 +104,4 @@ break;

}
if (n > 0xFF) {
throw new Error('byte overflow');
if (n > 0xFFFFFFFF) {
throw new Error('too large');
}

@@ -88,0 +108,0 @@ i++;

@@ -5,3 +5,3 @@ {

"description": "Parse and lookup IP network blocks",
"version": "2.0.1",
"version": "2.0.2",
"homepage": "https://github.com/rs/node-netmask",

@@ -8,0 +8,0 @@ "bugs": "https://github.com/rs/node-netmask/issues",

@@ -9,21 +9,23 @@ Netmask

var Netmask = require('netmask').Netmask
```js
var Netmask = require('netmask').Netmask
var block = new Netmask('10.0.0.0/12');
block.base; // 10.0.0.0
block.mask; // 255.240.0.0
block.bitmask; // 12
block.hostmask; // 0.15.255.255
block.broadcast; // 10.15.255.255
block.size; // 1048576
block.first; // 10.0.0.1
block.last; // 10.15.255.254
var block = new Netmask('10.0.0.0/12');
block.base; // 10.0.0.0
block.mask; // 255.240.0.0
block.bitmask; // 12
block.hostmask; // 0.15.255.255
block.broadcast; // 10.15.255.255
block.size; // 1048576
block.first; // 10.0.0.1
block.last; // 10.15.255.254
block.contains('10.0.8.10'); // true
block.contains('10.8.0.10'); // true
block.contains('192.168.1.20'); // false
block.contains('10.0.8.10'); // true
block.contains('10.8.0.10'); // true
block.contains('192.168.1.20'); // false
block.forEach(function(ip, long, index));
block.forEach(function(ip, long, index));
block.next() // Netmask('10.16.0.0/12')
block.next() // Netmask('10.16.0.0/12')
```

@@ -35,11 +37,12 @@ Constructing

'216.240.32.0/24' // The preferred form.
'216.240.32.0/255.255.255.0'
'216.240.32.0', '255.255.255.0'
'216.240.32.0', 0xffffff00
'216.240.32.4' // A /32 block.
'0330.0360.040.04' // Octal form
'0xd8.0xf0.0x20.0x4' // Hex form
```
'216.240.32.0/24' // The preferred form.
'216.240.32.0/255.255.255.0'
'216.240.32.0', '255.255.255.0'
'216.240.32.0', 0xffffff00
'216.240.32.4' // A /32 block.
'0330.0360.040.04' // Octal form
'0xd8.0xf0.0x20.0x4' // Hex form
```
API

@@ -46,0 +49,0 @@ ---

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc