diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c9bff6..fcab25c 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.22.6 | 2020-03-08 | `network()` fixed DHCP linux, `diskLayout()` fixed linux | | 4.22.5 | 2020-03-04 | `graphics()` fixed vram macOS | | 4.22.4 | 2020-03-01 | `versions()` added dotnet, typings fix | | 4.22.3 | 2020-02-20 | `memLayout()` code cleanup | diff --git a/docs/gettingstarted.html b/docs/gettingstarted.html index ffe03ac..79ac04f 100644 --- a/docs/gettingstarted.html +++ b/docs/gettingstarted.html @@ -58,7 +58,7 @@

Node.js comes with some basic OS information, but I always wanted a little more. So I came up to write this little library. This library is still work in progress. It is supposed to be used as a backend/server-side library (will definilely not work within a browser). It requires node.js version 4.0 and above.

-

I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra) and some Windows 7, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines. +

I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave) and some Windows 7, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines. Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details.

If you have comments, suggestions & reports, please feel free to contact me on github!

I also created a nice little command line tool called mmon (micro-monitor) for Linux and macOS, also available via github and npm

diff --git a/docs/history.html b/docs/history.html index 5e40337..cfe1638 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.22.6 + 2020-03-08 + network() fixed DHCP detection (linux) + 4.22.5 2020-03-04 diff --git a/docs/index.html b/docs/index.html index 1924802..303449c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.22.5
+
Current Version: 4.22.6
@@ -207,7 +207,7 @@
Downloads last month
-
250
+
251
Dependends
diff --git a/lib/filesystem.js b/lib/filesystem.js index e3d35a8..5ff3e38 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -745,14 +745,14 @@ function diskLayout(callback) { try { const outJSON = JSON.parse(out); if (outJSON && {}.hasOwnProperty.call(outJSON, 'blockdevices')) { - devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null; }); + devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && (item.model !== null || (item.mountpoint === null && item.label === null && item.fstype === null)); }); } } catch (e) { // fallback to older version of lsblk const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL').toString(); let lines = blkStdoutToObject(out2).split('\n'); const data = parseBlk(lines); - devices = data.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null && item.model !== ''; }); + devices = data.filter(item => { return item.group === 'disk' && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mountpoint === '' && item.label === '' && item.fstype === '')); }); } devices.forEach((device) => { let mediumType = ''; diff --git a/lib/network.js b/lib/network.js index bcce86c..ca48159 100644 --- a/lib/network.js +++ b/lib/network.js @@ -489,6 +489,26 @@ function getLinuxIfaceConnectionName(interfaceName) { } } +function checkLinuxDCHPInterfaces(file) { + let result = []; + let cmd = `cat ${file} 2> /dev/null | grep 'iface\\|source'`; + const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n'); + + lines.forEach(line => { + const parts = line.replace(/\s+/g, ' ').trim().split(' '); + if (parts.length >= 4) { + if (line.toLowerCase().indexOf(' inet ') >= 0 && line.toLowerCase().indexOf('dhcp') >= 0) { + result.push(parts[1]); + } + } + if (line.toLowerCase().includes('source')) { + let file = line.split(' ')[1]; + result = result.concat(checkLinuxDCHPInterfaces(file)); + } + }); + return result; +} + function getLinuxDHCPNics() { // alternate methods getting interfaces using DHCP let cmd = 'ip a 2> /dev/null'; @@ -501,16 +521,7 @@ function getLinuxDHCPNics() { util.noop(); } try { - cmd = 'cat /etc/network/interfaces 2> /dev/null | grep iface'; - const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n'); - lines.forEach(line => { - const parts = line.replace(/\s+/g, ' ').trim().split(' '); - if (parts.length >= 4) { - if (line.toLowerCase().indexOf(' inet ') >= 0 && line.toLowerCase().indexOf('dhcp') >= 0) { - result.push(parts[1]); - } - } - }); + result = checkLinuxDCHPInterfaces('/etc/network/interfaces'); } catch (e) { util.noop(); } @@ -1423,20 +1434,20 @@ function networkGatewayDefault(callback) { callback(result); } resolve(result); - // } else { - // exec('ipconfig', util.execOptsWin, function (error, stdout) { - // let lines = stdout.toString().split('\r\n'); - // lines.forEach(function (line) { - // line = line.trim().replace(/\. /g, ''); - // line = line.trim().replace(/ +/g, ''); - // const parts = line.split(':'); - // if ((parts[0].toLowerCase().startsWith('standardgate') || parts[0].toLowerCase().indexOf('gateway') > -1 || parts[0].toLowerCase().indexOf('enlace') > -1) && parts[1]) { - // result = parts[1]; - // } - // }); - // if (callback) { callback(result); } - // resolve(result); - // }); + // } else { + // exec('ipconfig', util.execOptsWin, function (error, stdout) { + // let lines = stdout.toString().split('\r\n'); + // lines.forEach(function (line) { + // line = line.trim().replace(/\. /g, ''); + // line = line.trim().replace(/ +/g, ''); + // const parts = line.split(':'); + // if ((parts[0].toLowerCase().startsWith('standardgate') || parts[0].toLowerCase().indexOf('gateway') > -1 || parts[0].toLowerCase().indexOf('enlace') > -1) && parts[1]) { + // result = parts[1]; + // } + // }); + // if (callback) { callback(result); } + // resolve(result); + // }); } }); } else {