From 7eb83e256543037a4a3835dd6daf66cfd555e206 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 23 Dec 2024 09:39:58 +0100 Subject: [PATCH] fix networkConnections() --- 2 | 2 -- CHANGELOG.md | 3 ++- docs/history.html | 5 +++++ docs/index.html | 2 +- lib/network.js | 14 ++++---------- lib/wifi.js | 2 +- 6 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 2 diff --git a/2 b/2 deleted file mode 100644 index 5d8b2f0..0000000 --- a/2 +++ /dev/null @@ -1,2 +0,0 @@ -WARNING: The airport command line tool is deprecated and will be removed in a future release. -For diagnosing Wi-Fi related issues, use the Wireless Diagnostics app or wdutil command line tool. diff --git a/CHANGELOG.md b/CHANGELOG.md index 15d9aa4..fd25a0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,7 +90,8 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | ------- | ---------- | --------------------------------------------------------------------------------------------------- | -| 5.23.16 | 2024-12-13 | `networkConnections()` refactored PID parsing (macOS) | +| 5.23.17 | 2024-12-23 | `wifiConnections()` refactored - Sequoia compatibel (macOS) | +| 5.23.16 | 2024-12-22 | `networkConnections()` refactored PID parsing (macOS) | | 5.23.15 | 2024-12-21 | `users()`, `wifiNetworks()` fixed parsing (macOS Seguoia) | | 5.23.14 | 2024-12-18 | `chassis()` new chassis detection (macOS) | | 5.23.13 | 2024-12-14 | `wifiConnections()` improved BSSID parsing (windows) | diff --git a/docs/history.html b/docs/history.html index 29c43ea..b24d46d 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.23.17 + 2024-12-23 + wifiConnections() refactored - Sequoia compatibel (macOS) + 5.23.16 2024-12-22 diff --git a/docs/index.html b/docs/index.html index a4192ee..70155b9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.23.16
+
New Version: 5.23.17
diff --git a/lib/network.js b/lib/network.js index bce8694..084adb3 100644 --- a/lib/network.js +++ b/lib/network.js @@ -1535,7 +1535,7 @@ function networkConnections(callback) { }); } if (_darwin) { - let cmd = 'netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6"'; + let cmd = 'netstat -natvln | head -n2; netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6"'; const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT_1|FIN_WAIT2|FIN_WAIT_2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN'.split('|'); exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) { if (!error) { @@ -1543,15 +1543,9 @@ function networkConnections(callback) { let processes = stdout2.toString().split('\n'); processes = processes.map((line => { return line.trim().replace(/ +/g, ' '); })); let lines = stdout.toString().split('\n'); - let pidPos = 8; - if (lines[0] !== '') { - const lineParts = lines[0].replace(/ +/g, ' ').split(' '); - for (let i = 0; i < lineParts.length; i++) { - if (states.indexOf(lineParts[i]) >= 0) { - pidPos = i + 3; - } - }; - } + lines.shift(); + const header = lines.shift().replace(/ Address/g, '_Address').replace(/ +/g, ' ').split(' '); + let pidPos = header.indexOf('pid'); lines.forEach(function (line) { line = line.replace(/ +/g, ' ').split(' '); if (line.length >= 8) { diff --git a/lib/wifi.js b/lib/wifi.js index 715aa6f..ee8492e 100644 --- a/lib/wifi.js +++ b/lib/wifi.js @@ -176,7 +176,7 @@ function ifaceListLinux() { } function nmiDeviceLinux(iface) { - const cmd = `nmcli -t -f general,wifi-properties,capabilities,ip4,ip6 device show ${iface} 2>/dev/null`; + const cmd = `nmcli -t -f general,wifi-properties,capabilities,ip4,ip6 device show ${iface} 2> /dev/null`; try { const lines = execSync(cmd, util.execOptsLinux).toString().split('\n'); const ssid = util.getValue(lines, 'GENERAL.CONNECTION');