diff --git a/README.md b/README.md index 8f0cd36..2329097 100644 --- a/README.md +++ b/README.md @@ -328,6 +328,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m | si.uuid(cb) | {...} | X | X | X | X | X | object of several UUIDs | | | os | X | X | X | X | | os specific UUID | | | hardware | X | X | X | X | | hardware specific UUID | +| | macs | X | X | X | X | | MAC addresses | | si.versions(apps, cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...)
apps param is optional for detecting
only specific apps/libs
(string, comma separated) | | si.shell(cb) | : string | X | X | X | | | standard shell | | si.users(cb) | [{...}] | X | X | X | X | X | array of users online | diff --git a/docs/os.html b/docs/os.html index baf9c70..ba996cd 100644 --- a/docs/os.html +++ b/docs/os.html @@ -240,36 +240,6 @@ si.osInfo().then(data => console.log(data)); uefi: true } - - si.uuid(cb) - {...} - X - X - X - X - X - object of several UUIDs - - - - os - X - X - X - X - - os specific UUID - - - - hardware - X - X - X - X - - hardware specific UUID - si.shell(cb) : string @@ -768,4 +738,4 @@ si.users().then(data => console.log(data)); - + \ No newline at end of file diff --git a/docs/system.html b/docs/system.html index 6e3dbc3..7938d0c 100644 --- a/docs/system.html +++ b/docs/system.html @@ -182,6 +182,64 @@ si.system().then(data => console.log(data)); sku: 'Mac-99878xxxx...', virtual: false, } + + + + si.uuid(cb) + {...} + X + X + X + X + X + object of several UUIDs + + + + os + X + X + X + X + + os specific UUID + + + + hardware + X + X + X + X + + hardware specific UUID + + + + macs + X + X + X + X + + MAC addresses + + + + +
Example
+
const si = require('systeminformation');
+si.uuid().then(data => console.log(data));
+
+{
+  os: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
+  hardware: 'xxxxxxxxxxxxxx',
+  macs: [
+    '01:02:03:04:05:06',
+    '02:03:04:05:06:07',
+    'aa:bb:cc:dd:ee:ff'
+  ]
+}
 
@@ -473,4 +531,4 @@ si.chassis().then(data => console.log(data)); - + \ No newline at end of file diff --git a/lib/osinfo.js b/lib/osinfo.js index 50b7f29..a35ec8a 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -960,13 +960,37 @@ function shell(callback) { exports.shell = shell; +function getUniqueMacAdresses() { + const ifaces = os.networkInterfaces(); + let macs = []; + for (let dev in ifaces) { + if ({}.hasOwnProperty.call(ifaces, dev)) { + ifaces[dev].forEach(function (details) { + if (details && details.mac && details.mac !== '00:00:00:00:00:00') { + const mac = details.mac.toLowerCase(); + if (macs.indexOf(mac) === -1) { + macs.push(mac); + } + } + }); + } + } + macs = macs.sort(function (a, b) { + if (a < b) { return -1; } + if (a > b) { return 1; } + return 0; + }); + return macs; +} + function uuid(callback) { return new Promise((resolve) => { process.nextTick(() => { let result = { os: '', - hardware: '' + hardware: '', + macs: getUniqueMacAdresses() }; let parts;