networkStats() fixed issue blocking windows
This commit is contained in:
+21
-19
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user