Socket
Socket
Sign inDemoInstall

ip

Package Overview
Dependencies
0
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

5

lib/ip.js

@@ -202,3 +202,3 @@ var ip = exports,

addr.match(/^192\.168\.([0-9]{1,3})\.([0-9]{1,3})/) != null ||
addr.match(/^172\.16\.([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 ||

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

// the specified `name`:
// * String: First `family` address of the interface. If not found see `undefined`.
// * String: First `family` address of the interface.
// If not found see `undefined`.
// * 'public': the first public ip address of family.

@@ -246,0 +247,0 @@ // * 'private': the first private ip address of family.

2

package.json
{
"name": "ip",
"version": "0.1.0",
"version": "0.2.0",
"author": "Fedor Indutny <fedor@indutny.com>",

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

# IP
IP address utilities for node.js
## Usage
Get your ip address, compare ip addresses, validate ip addresses, etc.

@@ -10,2 +10,3 @@ ```

ip.address() // my ip address
ip.isEqual('::1', '::0:1'); // true

@@ -12,0 +13,0 @@ ip.toBuffer('127.0.0.1') // Buffer([127, 0, 0, 1])

@@ -66,6 +66,8 @@ var ip = require('..'),

it('should or bits in ipv6 addresses', function() {
assert.equal(ip.or('::ff', '::abcd:dcba:abcd:dcba'), '::abcd:dcba:abcd:dcff');
assert.equal(ip.or('::ff', '::abcd:dcba:abcd:dcba'),
'::abcd:dcba:abcd:dcff');
});
it('should or bits in mixed addresses', function() {
assert.equal(ip.or('0.0.0.255', '::abcd:dcba:abcd:dcba'), '::abcd:dcba:abcd:dcff');
assert.equal(ip.or('0.0.0.255', '::abcd:dcba:abcd:dcba'),
'::abcd:dcba:abcd:dcff');
});

@@ -89,4 +91,4 @@ });

});
describe('isPrivate() method', function() {

@@ -96,3 +98,3 @@ it('should check if an address is localhost', function() {

});
it('should check if an address is from a 192.168.x.x network', function() {

@@ -103,9 +105,12 @@ assert.equal(ip.isPrivate('192.168.0.123'), true);

});
it('should check if an address is from a 172.16.x.x network', function() {
it('should check if an address is from a 172.(16-31).x.x network', function() {
assert.equal(ip.isPrivate('172.16.0.5'), true);
assert.equal(ip.isPrivate('172.16.123.254'), true);
assert.equal(ip.isPrivate('171.16.0.5'), false);
assert.equal(ip.isPrivate('172.25.232.15'), true);
assert.equal(ip.isPrivate('172.15.0.5'), false);
assert.equal(ip.isPrivate('172.32.0.5'), false);
});
it('should check if an address is from a 169.254.x.x network', function() {

@@ -116,3 +121,3 @@ assert.equal(ip.isPrivate('169.254.2.3'), true);

});
it('should check if an address is from a 10.x.x.x network', function() {

@@ -123,7 +128,7 @@ assert.equal(ip.isPrivate('10.0.2.3'), true);

});
it('should check if an address is from a private IPv6 network', function() {
assert.equal(ip.isPrivate('fe80::f2de:f1ff:fe3f:307e'), true);
});
it('should check if an address is from the internet', function() {

@@ -133,3 +138,3 @@ assert.equal(ip.isPrivate('165.225.132.33'), false); // joyent.com

});
describe('loopback() method', function () {

@@ -218,4 +223,3 @@ describe('undefined', function () {

});
describe('toLong() method', function(){

@@ -227,3 +231,3 @@ it('should respond with a int', function(){

});
describe('fromLong() method', function(){

@@ -235,3 +239,2 @@ it('should repond with ipv4 address', function(){

})
});
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