internal-ip
Advanced tools
Comparing version 2.0.1 to 2.0.2
12
index.js
'use strict'; | ||
const os = require('os'); | ||
const defaultGateway = require('default-gateway'); | ||
// TODO: Remove dependency on ip module | ||
// https://github.com/whitequark/ipaddr.js/issues/59 | ||
const ip = require('ip'); | ||
const ipaddr = require('ipaddr.js'); | ||
@@ -17,13 +14,10 @@ | ||
const interfaces = os.networkInterfaces(); | ||
const gatewayIp = ipaddr.parse(result.gateway); | ||
let ret; | ||
// Remove IPv6 zone index and parse gateway address as a ipaddr.js object | ||
// https://github.com/whitequark/ipaddr.js/issues/60 | ||
const gatewayIp = ipaddr.parse(result.gateway.replace(/%.+/, '')); | ||
// Look for the matching interface in all local interfaces | ||
Object.keys(interfaces).some(name => { | ||
return interfaces[name].some(addr => { | ||
const subnet = ip.subnet(addr.address, addr.netmask); | ||
const net = ipaddr.parseCIDR(`${addr.address}/${subnet.subnetMaskLength}`); | ||
const prefix = ipaddr.parse(addr.netmask).prefixLengthFromSubnetMask(); | ||
const net = ipaddr.parseCIDR(`${addr.address}/${prefix}`); | ||
@@ -30,0 +24,0 @@ if (net[0].kind() === gatewayIp.kind() && gatewayIp.match(net)) { |
{ | ||
"name": "internal-ip", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Get your internal IP address", | ||
@@ -34,5 +34,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"default-gateway": "^2.0.0", | ||
"ip": "^1.1.5", | ||
"ipaddr.js": "^1.4.0" | ||
"default-gateway": "^2.0.2", | ||
"ipaddr.js": "^1.5.1" | ||
}, | ||
@@ -39,0 +38,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2
0
3826
29
- Removedip@^1.1.5
- Removedip@1.1.9(transitive)
Updateddefault-gateway@^2.0.2
Updatedipaddr.js@^1.5.1