default-gateway
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"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}); |
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
Network access
Supply chain riskThis module accesses the network.
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
6920
7
91
5