Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

internal-ip

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

internal-ip - npm Package Compare versions

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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc