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

default-gateway

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

default-gateway - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

darwin.js

5

package.json
{
"name": "default-gateway",
"version": "1.0.1",
"version": "1.0.2",
"description": "Get the default network gateway, cross-platform.",

@@ -24,3 +24,4 @@ "author": "silverwind <me@silverwind.io>",

"index.js",
"unix.js",
"darwin.js",
"linux.js",
"win32.js"

@@ -27,0 +28,0 @@ ],

19

win32.js

@@ -6,8 +6,13 @@ "use strict";

const gwCmd = "wmic path Win32_NetworkAdapterConfiguration where IPEnabled=true get DefaultIPGateway,Index /format:table";
const ifCmd = "wmic path Win32_NetworkAdapter get Index,NetConnectionID /format:table";
function wmic(proto) {
return new Promise(function(resolve, reject) {
let gateway, gwid;
exec("wmic path Win32_NetworkAdapterConfiguration where IPEnabled=true get DefaultIPGateway,Index /format:table", function(_, gwtable) {
exec("wmic path Win32_NetworkAdapter get Index,NetConnectionID /format:table", function(_, iftable) {
gwtable.trim().split("\n").splice(1).some(function(line) {
exec(gwCmd, function(err, gwTable) {
if (err) return reject(err);
exec(ifCmd, function(err, ifTable) {
if (err) return reject(err);
(gwTable || "").trim().split("\n").splice(1).some(function(line) {
const [gw, id] = line.trim().split(/} +/);

@@ -20,6 +25,6 @@ gateway = (ipRegex[proto]().exec((gw || "").trim()) || [])[0];

});
iftable.trim().split("\n").splice(1).some(function(line) {
const spaceIndex = line.indexOf(" ");
const id = line.substr(0, spaceIndex).trim();
const name = line.substr(spaceIndex + 1).trim();
(ifTable || "").trim().split("\n").splice(1).some(function(line) {
const i = line.indexOf(" ");
const id = line.substr(0, i).trim();
const name = line.substr(i + 1).trim();
if (id === gwid) {

@@ -26,0 +31,0 @@ resolve({gateway: gateway, interface: name ? name : null});

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