Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Node.js utility package for working with IP addresses and CIDR ranges.
$ npm install netaddr --save
var Addr = require('netaddr').Addr;
// Create a fixed IP address from a string
var localhost = Addr('127.0.0.1');
// Create CIDR range from a string
var subnet = Addr('10.0.0.0/16');
// Create a CIDR range from an integer and prefix
var subnet = Addr(167772160, 16);
// Convert an IP address to an integer
var intval = Addr('127.0.0.1').toInt();
// Get the network address
var network = subnet.network();
// Get the broadcast address
var broadcast = subnet.broadcast();
// Mask the address with a new prefix
var masked = subnet.mask(24);
// Check if one CIDR contains another CIDR or IP
subnet.contains(Addr('10.0.3.0/24')); // true
// Check where two CIDRs intersect
subnet.intersect(Addr('10.0.3.0/24'));
// Increment an address (non-mutating)
localhost.increment();
// Decrement an address (non-mutating)
localhost.decrement();
// Find the next adjacent subnet
subnet.nextSibling();
// Find the previous adjacent subnet
subnet.prevSibling();
Attempts to create an invalid Addr
will throw an Error
.
Currently only IPv4 is supported, though there are plans to add IPv6 support. This is complicated by the fact JavaScript does not support 64-bit integers, let alone 128-bit integers.
Copyright © 2015 Chris Corbyn. See the LICENSE file for details.
FAQs
Utility for IP addresses and CIDR expressions
The npm package netaddr receives a total of 2,429 weekly downloads. As such, netaddr popularity was classified as popular.
We found that netaddr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.