From 860dec226091ed7204d9b9096aac9282bbf09379 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 3 Feb 2019 09:16:39 +0100 Subject: [PATCH] networkInterfaces(), chassis() fixed two more issues --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ lib/network.js | 2 +- lib/system.js | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70712dc..a7a07b0 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.0.3 | 2019-02-03 | `networkInterfaces(), chassis()` fixed two more issues | | 4.0.2 | 2019-02-03 | `networkInterfaces(), chassis()` fixed smaller issues | | 4.0.1 | 2019-02-02 | updated docs | | 4.0.0 | 2019-02-02 | new major version | diff --git a/docs/history.html b/docs/history.html index e60ec9c..a348709 100644 --- a/docs/history.html +++ b/docs/history.html @@ -55,6 +55,11 @@ + + 4.0.3 + 2019-02-03 + networkInterfaces(), chassis() fixed two more issues + 4.0.2 2019-02-03 diff --git a/lib/network.js b/lib/network.js index e4260a7..0deabdd 100644 --- a/lib/network.js +++ b/lib/network.js @@ -335,7 +335,7 @@ function networkInterfaces(callback) { echo -n "speed: "; cat /sys/class/net/${iface}/speed 2>/dev/null; echo; echo -n "tx_queue_len: "; cat /sys/class/net/${iface}/tx_queue_len 2>/dev/null; echo; echo -n "type: "; cat /sys/class/net/${iface}/type 2>/dev/null; echo; - echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null \| grep ${iface}; + echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null \| grep ${iface}; echo echo -n "wirelessspeed: "; iw dev ${iface} link 2>&1 \| grep bitrate; echo;`; let lines = []; try { diff --git a/lib/system.js b/lib/system.js index 5ff13ce..a9220ac 100644 --- a/lib/system.js +++ b/lib/system.js @@ -493,7 +493,8 @@ function chassis(callback) { exec(cmd, function (error, stdout) { let lines = stdout.toString().split('\n'); result.manufacturer = util.getValue(lines, 'chassis_vendor'); - result.type = util.getValue(lines, 'chassis_type'); + const ctype = parseInt(util.getValue(lines, 'chassis_type').replace(/\D/g, '')); + result.type = (ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype - 1] : ''; result.version = util.getValue(lines, 'chassis_version'); result.serial = util.getValue(lines, 'chassis_serial'); result.assetTag = util.getValue(lines, 'chassis_asset_tag');