From bc71d324d91a1e2582f2765b849f728d7ff257b9 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Thu, 4 Aug 2022 07:49:41 +0200 Subject: [PATCH] networkInterfaces() operstate fix (mac OS) --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 4 ++-- lib/network.js | 4 +++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8c7674..72bbc22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 5.12.3 | 2022-08-04 | `networkInterfaces()` operstate fix (mac OS) | | 5.12.2 | 2022-08-01 | `services()` Ubuntu 22.04 fix | | 5.12.1 | 2022-07-14 | `cpuTemperature()` Apple Silicon support (see docs) | | 5.12.0 | 2022-07-12 | `cpu()` added performance and efficiency cores (linux) | diff --git a/docs/history.html b/docs/history.html index 763df7b..a0925ce 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.12.3 + 2022-08-04 + networkInterfaces() operstate fix (mac OS) + 5.12.2 2022-08-01 diff --git a/docs/index.html b/docs/index.html index f385143..462f270 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.12.2
+
New Version: 5.12.3
@@ -214,7 +214,7 @@
Downloads last month
-
550
+
557
Dependents
diff --git a/lib/network.js b/lib/network.js index ae224bc..ec051be 100644 --- a/lib/network.js +++ b/lib/network.js @@ -494,7 +494,9 @@ function parseLinesDarwinNics(sections) { } } nic.type = util.getValue(section, 'type').toLowerCase().indexOf('wi-fi') > -1 ? 'wireless' : 'wired'; - nic.operstate = util.getValue(section, 'status').toLowerCase().indexOf('active') > -1 ? 'up' : 'down'; + const operstate = util.getValue(section, 'status').toLowerCase(); + nic.operstate = (operstate === 'active' ? 'up' : (operstate === 'inactive' ? 'down' : 'unknown')); + // nic.operstate = util.getValue(section, 'status').toLowerCase().indexOf('active') > -1 ? 'up' : 'down'; nic.duplex = util.getValue(section, 'media').toLowerCase().indexOf('half-duplex') > -1 ? 'half' : 'full'; if (nic.ip6 || nic.ip4 || nic.mac) { nics.push(nic);