default interface name windows optimization
This commit is contained in:
parent
f937c8a5f4
commit
b90c1c8a97
@ -59,6 +59,23 @@ function getDefaultNetworkInterface() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifacename = ifacename || ifacenameFirst || '';
|
ifacename = ifacename || ifacenameFirst || '';
|
||||||
|
|
||||||
|
if (_windows) {
|
||||||
|
// https://www.inetdaemon.com/tutorials/internet/ip/routing/default_route.shtml
|
||||||
|
const cmd = 'netstat -r';
|
||||||
|
const result = execSync(cmd);
|
||||||
|
const lines = result.toString().split(os.EOL)[0];
|
||||||
|
const defaultIp = util.getValue('Default Gateway', lines, ':');
|
||||||
|
for (let dev in ifaces) {
|
||||||
|
if (ifaces.hasOwnProperty(dev)) {
|
||||||
|
ifaces[dev].forEach(function (details) {
|
||||||
|
if (details && details.address && details.address === defaultIp) {
|
||||||
|
ifacename = dev;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (_linux || _darwin || _freebsd || _openbsd || _netbsd || _sunos) {
|
if (_linux || _darwin || _freebsd || _openbsd || _netbsd || _sunos) {
|
||||||
let cmd = '';
|
let cmd = '';
|
||||||
if (_linux) cmd = 'ip route 2> /dev/null | grep default | awk \'{print $5}\'';
|
if (_linux) cmd = 'ip route 2> /dev/null | grep default | awk \'{print $5}\'';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user