From fd5b435f8d1b60011e02d5bb268da2247ce42359 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Thu, 16 Jul 2020 10:43:01 +0200 Subject: [PATCH] networkStats() fixed issue blocking windows --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 4 ++-- lib/network.js | 40 +++++++++++++++++++++------------------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 408b1df..488eaca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.26.10 | 2020-07-16 | `networkStats()` fixed issue blocking windows | | 4.26.9 | 2020-06-06 | `networkStats()` fixed comparison issue windows | | 4.26.8 | 2020-06-06 | `networkInterfaces()` fixed caching issue | | 4.26.7 | 2020-06-06 | `cpuTemperature()` fixed raspberry pi sensors issue | diff --git a/docs/history.html b/docs/history.html index 5c6a0b8..3f1f402 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.26.10 + 2020-07-16 + networkStats() fixed issue blocking windows + 4.26.9 2020-06-06 diff --git a/docs/index.html b/docs/index.html index 52fef41..da715ef 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.26.9
+
Current Version: 4.26.10
@@ -207,7 +207,7 @@
Downloads last month
-
283
+
304
Dependends
diff --git a/lib/network.js b/lib/network.js index e7a510a..c44d329 100644 --- a/lib/network.js +++ b/lib/network.js @@ -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();