networkStats() fixed issue blocking windows

This commit is contained in:
Sebastian Hildebrandt
2020-07-16 10:43:01 +02:00
parent dc62e51750
commit fd5b435f8d
4 changed files with 29 additions and 21 deletions
+21 -19
View File
@@ -31,7 +31,7 @@ const _sunos = (_platform === 'sunos');
let _network = {};
let _default_iface = '';
let _ifaces = [];
let _ifaces = {};
let _dhcpNics = [];
let _networkInterfaces = [];
let _mac = {};
@@ -686,24 +686,7 @@ function networkInterfaces(callback, rescan = true) {
return new Promise((resolve) => {
process.nextTick(() => {
let ifaces = os.networkInterfaces();
if (_windows) {
getWindowsNics().forEach(nic => {
let found = false;
Object.keys(ifaces).forEach(key => {
if (!found) {
ifaces[key].forEach(value => {
if (Object.keys(value).indexOf('mac') >= 0) {
found = value['mac'] === nic.mac;
}
});
}
});
if (!found) {
ifaces[nic.name] = [{ mac: nic.mac }];
}
});
}
let result = [];
let nics = [];
let dnsSuffixes = [];
@@ -748,6 +731,7 @@ function networkInterfaces(callback, rescan = true) {
carrierChanges: 0
});
});
_networkInterfaces = result;
if (callback) { callback(result); }
resolve(result);
} else {
@@ -758,8 +742,26 @@ function networkInterfaces(callback, rescan = true) {
if (callback) { callback(result); }
resolve(result);
} else {
_ifaces = ifaces;
_ifaces = Object.assign({}, ifaces);
if (_windows) {
getWindowsNics().forEach(nic => {
let found = false;
Object.keys(ifaces).forEach(key => {
if (!found) {
ifaces[key].forEach(value => {
if (Object.keys(value).indexOf('mac') >= 0) {
found = value['mac'] === nic.mac;
}
});
}
});
if (!found) {
ifaces[nic.name] = [{ mac: nic.mac }];
}
});
nics8021xInfo = getWindowsWiredProfilesInformation();
nics = getWindowsNics();
dnsSuffixes = getWindowsDNSsuffixes();