Socket
Socket
Sign inDemoInstall

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 1.0.6 to 2.0.0

63

lib/netmask.js

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.10.0
// Generated by CoffeeScript 1.12.7
(function() {

@@ -22,3 +22,12 @@ var Netmask, ip2long, long2ip;

byte = b[i];
if (isNaN(parseInt(byte, 10))) {
if (byte && byte[0] === '0') {
if (byte.length > 2 && (byte[1] === 'x' || byte[1] === 'x')) {
byte = parseInt(byte, 16);
} else {
byte = parseInt(byte, 8);
}
} else {
byte = parseInt(byte, 10);
}
if (isNaN(byte)) {
throw new Error("Invalid byte: " + byte);

@@ -29,4 +38,8 @@ }

}
b[i] = byte;
}
return ((b[0] || 0) << 24 | (b[1] || 0) << 16 | (b[2] || 0) << 8 | (b[3] || 0)) >>> 0;
while (b.length < 4) {
b.unshift(0);
}
return (b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3]) >>> 0;
};

@@ -36,3 +49,3 @@

function Netmask(net, mask) {
var error, error1, error2, i, j, ref;
var error, i, j, ref;
if (typeof net !== 'string') {

@@ -45,18 +58,3 @@ throw new Error("Missing `net' parameter");

if (!mask) {
switch (net.split('.').length) {
case 1:
mask = 8;
break;
case 2:
mask = 16;
break;
case 3:
mask = 24;
break;
case 4:
mask = 32;
break;
default:
throw new Error("Invalid net address: " + net);
}
mask = 32;
}

@@ -76,3 +74,3 @@ if (typeof mask === 'string' && mask.indexOf('.') > -1) {

}
} else if (mask) {
} else if (mask || mask === 0) {
this.bitmask = parseInt(mask, 10);

@@ -88,4 +86,4 @@ this.maskLong = 0;

this.netLong = (ip2long(net) & this.maskLong) >>> 0;
} catch (error2) {
error = error2;
} catch (error1) {
error = error1;
throw new Error("Invalid net address: " + net);

@@ -124,14 +122,11 @@ }

Netmask.prototype.forEach = function(fn) {
var index, j, k, len, long, range, ref, ref1, results, results1;
range = (function() {
results = [];
for (var j = ref = ip2long(this.first), ref1 = ip2long(this.last); ref <= ref1 ? j <= ref1 : j >= ref1; ref <= ref1 ? j++ : j--){ results.push(j); }
return results;
}).apply(this);
results1 = [];
for (index = k = 0, len = range.length; k < len; index = ++k) {
long = range[index];
results1.push(fn(long2ip(long), long, index));
var index, lastLong, long;
long = ip2long(this.first);
lastLong = ip2long(this.last);
index = 0;
while (long <= lastLong) {
fn(long2ip(long), long, index);
index++;
long++;
}
return results1;
};

@@ -138,0 +133,0 @@

@@ -5,24 +5,29 @@ {

"description": "Parse and lookup IP network blocks",
"version": "1.0.6",
"version": "2.0.0",
"homepage": "https://github.com/rs/node-netmask",
"bugs": "https://github.com/rs/node-netmask/issues",
"license": "MIT",
"repository":
{
"repository": {
"type": "git",
"url": "git://github.com/rs/node-netmask.git"
},
"keywords": ["net", "mask", "ip", "network", "cidr", "netmask", "subnet", "ipcalc"],
"keywords": [
"net",
"mask",
"ip",
"network",
"cidr",
"netmask",
"subnet",
"ipcalc"
],
"main": "./lib/netmask",
"scripts":
{
"scripts": {
"prepublish": "coffee -c lib/*.coffee",
"test": "vows --spec test/*"
},
"engines":
{
"engines": {
"node": ">= 0.4.0"
},
"devDependencies":
{
"devDependencies": {
"coffee-script": ">=1.2.0",

@@ -29,0 +34,0 @@ "vows": "*"

@@ -39,8 +39,6 @@ Netmask

'216.240.32.4' // A /32 block.
'216.240.32' // A /24 block.
'216.240' // A /16 block.
'140' // A /8 block.
'216.240.32/24'
'216.240/16'
'0330.0360.040.04' // Octal form
'0xd8.0xf0.0x20.0x4' // Hex form
API

@@ -71,3 +69,3 @@ ---

Copyright (c) 2011 Olivier Poitrey <rs@dailymotion.com>
Copyright (c) 2011 Olivier Poitrey <rs@rhapsodyk.net>

@@ -74,0 +72,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

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