Socket
Socket
Sign inDemoInstall

ip

Package Overview
Dependencies
0
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.1 to 0.3.2

14

lib/ip.js

@@ -163,8 +163,13 @@ var ip = exports,

networkAddress: ip.fromLong(networkAddress),
firstAddress: ip.fromLong(networkAddress + 1),
lastAddress: ip.fromLong(networkAddress + numberOfAddresses - 2),
firstAddress: numberOfAddresses <= 2 ?
ip.fromLong(networkAddress) :
ip.fromLong(networkAddress + 1),
lastAddress: numberOfAddresses <= 2 ?
ip.fromLong(networkAddress + numberOfAddresses - 1) :
ip.fromLong(networkAddress + numberOfAddresses - 2),
broadcastAddress: ip.fromLong(networkAddress + numberOfAddresses - 1),
subnetMask: mask,
subnetMaskLength: maskLength,
numHosts: numberOfAddresses - 2,
numHosts: numberOfAddresses <= 2 ?
numberOfAddresses : numberOfAddresses - 2,
length: numberOfAddresses

@@ -260,3 +265,4 @@ };

addr.match(/^192\.168\.([0-9]{1,3})\.([0-9]{1,3})/) != null ||
addr.match(/^172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})/) != null ||
addr.match(
/^172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})/) != null ||
addr.match(/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/) != null ||

@@ -263,0 +269,0 @@ addr.match(/^169\.254\.([0-9]{1,3})\.([0-9]{1,3})/) != null ||

{
"name": "ip",
"version": "0.3.1",
"version": "0.3.2",
"author": "Fedor Indutny <fedor@indutny.com>",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/indutny/node-ip",

@@ -119,2 +119,34 @@ var ip = require('..'),

describe('subnet() method with mask length 32', function() {
// Test cases calculated with http://www.subnet-calculator.com/
var ipv4Subnet = ip.subnet('192.168.1.134', '255.255.255.255');
it('should compute ipv4 network\'s first address', function() {
assert.equal(ipv4Subnet.firstAddress, '192.168.1.134');
});
it('should compute ipv4 network\'s last address', function() {
assert.equal(ipv4Subnet.lastAddress, '192.168.1.134');
});
it('should compute ipv4 subnet number of addressable hosts', function() {
assert.equal(ipv4Subnet.numHosts, 1);
});
});
describe('subnet() method with mask length 31', function() {
// Test cases calculated with http://www.subnet-calculator.com/
var ipv4Subnet = ip.subnet('192.168.1.134', '255.255.255.254');
it('should compute ipv4 network\'s first address', function() {
assert.equal(ipv4Subnet.firstAddress, '192.168.1.134');
});
it('should compute ipv4 network\'s last address', function() {
assert.equal(ipv4Subnet.lastAddress, '192.168.1.135');
});
it('should compute ipv4 subnet number of addressable hosts', function() {
assert.equal(ipv4Subnet.numHosts, 2);
});
});
describe('cidrSubnet() method', function() {

@@ -121,0 +153,0 @@ // Test cases calculated with http://www.subnet-calculator.com/

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