node-ip

IP address tools for node.js

Subscribe to updates I use node-ip


Statistics on node-ip

Number of watchers on Github 739
Number of open issues 43
Average time to close an issue 2 months
Main language JavaScript
Average time to merge a PR about 1 month
Open pull requests 15+
Closed pull requests 16+
Last commit over 1 year ago
Repo Created over 6 years ago
Repo Last Updated 8 months ago
Size 68 KB
Organization / Authorindutny
Contributors20
Page Updated
Do you use node-ip? Leave a review!
View open issues (43)
View node-ip activity
View on github
Latest Open Source Launches
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating node-ip for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

IP

IP address utilities for node.js

Installation

npm

npm install ip

git

git clone https://github.com/indutny/node-ip.git

Usage

Get your ip address, compare ip addresses, validate ip addresses, etc.

var ip = require('ip');

ip.address() // my ip address
ip.isEqual('::1', '::0:1'); // true
ip.toBuffer('127.0.0.1') // Buffer([127, 0, 0, 1])
ip.toString(new Buffer([127, 0, 0, 1])) // 127.0.0.1
ip.fromPrefixLen(24) // 255.255.255.0
ip.mask('192.168.1.134', '255.255.255.0') // 192.168.1.0
ip.cidr('192.168.1.134/26') // 192.168.1.128
ip.not('255.255.255.0') // 0.0.0.255
ip.or('192.168.1.134', '0.0.0.255') // 192.168.1.255
ip.isPrivate('127.0.0.1') // true
ip.isV4Format('127.0.0.1'); // true
ip.isV6Format('::ffff:127.0.0.1'); // true

// operate on buffers in-place
var buf = new Buffer(128);
var offset = 64;
ip.toBuffer('127.0.0.1', buf, offset);  // [127, 0, 0, 1] at offset 64
ip.toString(buf, offset, 4);            // '127.0.0.1'

// subnet information
ip.subnet('192.168.1.134', '255.255.255.192')
// { networkAddress: '192.168.1.128',
//   firstAddress: '192.168.1.129',
//   lastAddress: '192.168.1.190',
//   broadcastAddress: '192.168.1.191',
//   subnetMask: '255.255.255.192',
//   subnetMaskLength: 26,
//   numHosts: 62,
//   length: 64,
//   contains: function(addr){...} }
ip.cidrSubnet('192.168.1.134/26')
// Same as previous.

// range checking
ip.cidrSubnet('192.168.1.134/26').contains('192.168.1.190') // true


// ipv4 long conversion
ip.toLong('127.0.0.1'); // 2130706433
ip.fromLong(2130706433); // '127.0.0.1'

License

This software is licensed under the MIT License.

Copyright Fedor Indutny, 2012.

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-ip open issues Ask a question     (View All Issues)
  • about 2 years Bash on Windows networkinterface error
  • about 2 years dddd returning as valid V6 address
  • over 2 years Wrong IPv6 returned
  • over 2 years Consider adding a filter for invalid ip.
  • almost 3 years Comparing IPv4 with it's IPv6 equivalent
  • almost 3 years ip.isPrivate not contain all private ips
  • almost 3 years ip -> getMacAddress
  • almost 3 years partial ips for CIDR seem not valid
  • about 3 years cidrSubnet() is skipping first/last address
  • over 3 years Throw error if method doesn't support IPv6
  • over 3 years No need for regex to check for loopback anymore
  • over 3 years Code Coverage
  • over 3 years Unable to run (all the) tests on Mac 10.10.2 using Node 0.12.1
  • almost 4 years Getting wrong IP address on Mac OS X 10.10.1
  • almost 4 years IP returned is VMnet adapter - not ethernet address
  • almost 4 years cidrSubnet for ipv6 returns invalid result
node-ip open pull requests (View All Pulls)
  • Issue #42: cidrSubnet() is skipping first/last address
  • Add networkInterface function to be able to get the netmask associated with my ip address
  • do string comparisons in isLoopback, use isLoopback in isPrivate, make toBuffer less loopy
  • netClass method
  • Add function to generate a range of IP addresses
  • Fix logic of ip.address('public/private')
  • allow to get multiple addresses assign to interface
  • add all ip 0.0.0.0 to isPrivate and isLoopback
  • Adds a new utility: isValid()
  • address(name): name not found should respond with undefined
  • add toReverseDNS
  • chore(package): add description
  • Implement ip.range
  • TravisBuddy Integration
  • Sort interfaces by priority when searching an IP address
node-ip questions on Stackoverflow (View All Questions)
  • How can I get the correct ip address of the visitor in node.js? (I tried node-ip and it doesn't work)
  • How can I get mobile node IP address in OPNET 14.5?
  • AWS EMR - Get master node ip from java code
  • How to get elastic cache node ip address with cloud formation
  • Identify YARN's newly activated active node IP(passive node) using Apache Slider in case if a existing active node is down
  • Using a pod without using the node ip
  • making the node <node ip address >as done :cannot reach the noe for 2 tries
  • How to get exit node ip in PHP app running on tor/lighttpd
  • How does elasticsearch determine its node IP?
  • Getting remote node IP address in Selenium Grid env
  • How do I get the Tor exit node IP address over the control port?
  • How to find chef node ip by role
node-ip list of languages used
Other projects in JavaScript