+24
-8
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user