Merge pull request #2 from sebhildebrandt/master

Update from original
This commit is contained in:
Esteban Garcia
2019-12-17 14:29:00 -05:00
committed by GitHub
7 changed files with 37 additions and 15 deletions
+24 -8
View File
@@ -1336,16 +1336,33 @@ function networkGatewayDefault(callback) {
}
if (_windows) {
try {
util.powerShell('Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq \'0.0.0.0\' -and $_.Mask -eq \'0.0.0.0\' }).InterfaceIndex')
util.powerShell('Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq \'0.0.0.0\' -and $_.Mask -eq \'0.0.0.0\' }')
.then(data => {
let lines = data.toString().split('\r\n');
result = lines && lines[0] ? lines[0] : '';
if (callback) {
callback(result);
}
resolve(result);
if (lines.length > 1 && !result) {
result = util.getValue(lines, 'NextHop');
// result = lines && lines[0] ? lines[0] : '';
if (callback) {
callback(result);
}
resolve(result);
} else {
exec('ipconfig', util.execOptsWin, function (error, stdout) {
let lines = stdout.toString().split('\r\n');
lines.forEach(function (line) {
line = line.trim().replace(/\. /g, '');
line = line.trim().replace(/ +/g, '');
const parts = line.split(':');
if (parts[0].toLowerCase().startsWith('standardgate') && parts[1]) {
result = parts[1];
}
});
if (callback) { callback(result); }
resolve(result);
});
});
}
})
} catch (e) {
if (callback) { callback(result); }
resolve(result);
@@ -1355,5 +1372,4 @@ function networkGatewayDefault(callback) {
});
}
exports.networkGatewayDefault = networkGatewayDefault;