systeminformation 5.33.16 → 5.33.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/filesystem.js +2 -1
- package/lib/index.js +10 -8
- package/lib/network.js +19 -19
- package/lib/util.js +33 -23
- package/package.json +1 -1
package/lib/filesystem.js
CHANGED
|
@@ -261,7 +261,8 @@ function fsSize(drive, callback) {
|
|
|
261
261
|
data = parseDf(lines);
|
|
262
262
|
if (drive) {
|
|
263
263
|
data = data.filter((item) => {
|
|
264
|
-
|
|
264
|
+
// non-string drive input matches no drive (same as windows)
|
|
265
|
+
return typeof drive === 'string' && (item.fs.toLowerCase().indexOf(drive.toLowerCase()) >= 0 || item.mount.toLowerCase().indexOf(drive.toLowerCase()) >= 0);
|
|
265
266
|
});
|
|
266
267
|
}
|
|
267
268
|
if ((!error || data.length) && stdout.toString().trim() !== '') {
|
package/lib/index.js
CHANGED
|
@@ -149,7 +149,7 @@ function getDynamicData(srv, iface, callback) {
|
|
|
149
149
|
srv = srv || '';
|
|
150
150
|
|
|
151
151
|
// use closure to track ƒ completion
|
|
152
|
-
|
|
152
|
+
const functionProcessed = (() => {
|
|
153
153
|
let totalFunctions = 15;
|
|
154
154
|
if (_windows) {
|
|
155
155
|
totalFunctions = 13;
|
|
@@ -161,7 +161,7 @@ function getDynamicData(srv, iface, callback) {
|
|
|
161
161
|
totalFunctions = 6;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
return
|
|
164
|
+
return () => {
|
|
165
165
|
if (--totalFunctions === 0) {
|
|
166
166
|
if (callback) {
|
|
167
167
|
callback(data);
|
|
@@ -307,7 +307,7 @@ function getAllData(srv, iface, callback) {
|
|
|
307
307
|
getStaticData().then((res) => {
|
|
308
308
|
data = res;
|
|
309
309
|
getDynamicData(srv, iface).then((res) => {
|
|
310
|
-
for (
|
|
310
|
+
for (const key in res) {
|
|
311
311
|
if ({}.hasOwnProperty.call(res, key)) {
|
|
312
312
|
data[key] = res[key];
|
|
313
313
|
}
|
|
@@ -325,6 +325,7 @@ function getAllData(srv, iface, callback) {
|
|
|
325
325
|
function get(valueObject, callback) {
|
|
326
326
|
return new Promise((resolve) => {
|
|
327
327
|
process.nextTick(() => {
|
|
328
|
+
valueObject = valueObject || {};
|
|
328
329
|
const blocked = ['get', 'getStaticData', 'getDynamicData', 'getAllData', 'observe', 'powerShellStart', 'powerShellRelease'];
|
|
329
330
|
const isGettable = (key) => ({}).hasOwnProperty.call(exports, key) && typeof exports[key] === 'function' && typeof valueObject[key] === 'string' && blocked.indexOf(key) < 0;
|
|
330
331
|
const allPromises = Object.keys(valueObject)
|
|
@@ -333,17 +334,18 @@ function get(valueObject, callback) {
|
|
|
333
334
|
const params = valueObject[func].substring(valueObject[func].lastIndexOf('(') + 1, valueObject[func].lastIndexOf(')'));
|
|
334
335
|
let funcWithoutParams = func.indexOf(')') >= 0 ? func.split(')')[1].trim() : func;
|
|
335
336
|
funcWithoutParams = func.indexOf('|') >= 0 ? func.split('|')[0].trim() : funcWithoutParams;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
337
|
+
// a failing function yields an empty result for its key only
|
|
338
|
+
try {
|
|
339
|
+
return Promise.resolve(exports[funcWithoutParams](params || '')).catch(() => null);
|
|
340
|
+
} catch {
|
|
341
|
+
return Promise.resolve(null);
|
|
340
342
|
}
|
|
341
343
|
});
|
|
342
344
|
|
|
343
345
|
Promise.all(allPromises).then((data) => {
|
|
344
346
|
const result = {};
|
|
345
347
|
let i = 0;
|
|
346
|
-
for (
|
|
348
|
+
for (const key in valueObject) {
|
|
347
349
|
if ({}.hasOwnProperty.call(valueObject, key) && isGettable(key) && data.length > i) {
|
|
348
350
|
if (valueObject[key] === '*' || valueObject[key] === 'all') {
|
|
349
351
|
result[key] = data[i];
|
package/lib/network.js
CHANGED
|
@@ -49,7 +49,7 @@ function getDefaultNetworkInterface() {
|
|
|
49
49
|
let scopeid = 9999;
|
|
50
50
|
|
|
51
51
|
// fallback - "first" external interface (sorted by scopeid)
|
|
52
|
-
for (
|
|
52
|
+
for (const dev in ifaces) {
|
|
53
53
|
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
|
54
54
|
ifaces[dev].forEach((details) => {
|
|
55
55
|
if (details && details.internal === false) {
|
|
@@ -80,7 +80,7 @@ function getDefaultNetworkInterface() {
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
if (defaultIp) {
|
|
83
|
-
for (
|
|
83
|
+
for (const dev in ifaces) {
|
|
84
84
|
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
|
85
85
|
ifaces[dev].forEach((details) => {
|
|
86
86
|
if (details && details.address && details.address === defaultIp) {
|
|
@@ -224,7 +224,7 @@ exports.networkInterfaceDefault = networkInterfaceDefault;
|
|
|
224
224
|
|
|
225
225
|
function parseLinesWindowsNics(sections, nconfigsections) {
|
|
226
226
|
const nics = [];
|
|
227
|
-
for (
|
|
227
|
+
for (const i in sections) {
|
|
228
228
|
try {
|
|
229
229
|
if ({}.hasOwnProperty.call(sections, i)) {
|
|
230
230
|
if (sections[i].trim() !== '') {
|
|
@@ -602,7 +602,7 @@ function parseLinuxDHCPNics(sections) {
|
|
|
602
602
|
if (lines && lines.length) {
|
|
603
603
|
const parts = lines[0].split(':');
|
|
604
604
|
if (parts.length > 2) {
|
|
605
|
-
for (
|
|
605
|
+
for (const line of lines) {
|
|
606
606
|
if (line.indexOf(' inet ') >= 0 && line.indexOf(' dynamic ') >= 0) {
|
|
607
607
|
const parts2 = line.split(' ');
|
|
608
608
|
const nic = parts2[parts2.length - 1].trim();
|
|
@@ -762,8 +762,8 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|
|
762
762
|
if (typeof rescan === 'undefined') {
|
|
763
763
|
rescan = true;
|
|
764
764
|
}
|
|
765
|
-
|
|
766
|
-
defaultString = ''
|
|
765
|
+
// objects without string conversion would throw here
|
|
766
|
+
defaultString = typeof defaultString === 'string' ? defaultString : '';
|
|
767
767
|
|
|
768
768
|
return new Promise((resolve) => {
|
|
769
769
|
process.nextTick(() => {
|
|
@@ -882,7 +882,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|
|
882
882
|
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
|
883
883
|
_dhcpNics = getLinuxDHCPNics();
|
|
884
884
|
const defaultInterface = getDefaultNetworkInterface();
|
|
885
|
-
for (
|
|
885
|
+
for (const dev in ifaces) {
|
|
886
886
|
let ip4 = '';
|
|
887
887
|
let ip4subnet = '';
|
|
888
888
|
let ip6 = '';
|
|
@@ -1076,7 +1076,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|
|
1076
1076
|
});
|
|
1077
1077
|
nics8021xInfo = getWindowsWiredProfilesInformation();
|
|
1078
1078
|
dnsSuffixes = getWindowsDNSsuffixes();
|
|
1079
|
-
for (
|
|
1079
|
+
for (const dev in ifaces) {
|
|
1080
1080
|
const ifaceSanitized = util.sanitizeString(dev);
|
|
1081
1081
|
|
|
1082
1082
|
let iface = dev;
|
|
@@ -1085,10 +1085,10 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|
|
1085
1085
|
let ip6 = '';
|
|
1086
1086
|
let ip6subnet = '';
|
|
1087
1087
|
let mac = '';
|
|
1088
|
-
|
|
1089
|
-
|
|
1088
|
+
const duplex = '';
|
|
1089
|
+
const mtu = '';
|
|
1090
1090
|
let speed = null;
|
|
1091
|
-
|
|
1091
|
+
const carrierChanges = 0;
|
|
1092
1092
|
let operstate = 'down';
|
|
1093
1093
|
let dhcp = false;
|
|
1094
1094
|
let dnsSuffix = '';
|
|
@@ -1283,7 +1283,7 @@ function networkStats(ifaces, callback) {
|
|
|
1283
1283
|
if (ifacesArray.length && ifacesArray[0].trim() === '*') {
|
|
1284
1284
|
ifacesArray = [];
|
|
1285
1285
|
networkInterfaces(false).then((allIFaces) => {
|
|
1286
|
-
for (
|
|
1286
|
+
for (const iface of allIFaces) {
|
|
1287
1287
|
ifacesArray.push(iface.iface);
|
|
1288
1288
|
}
|
|
1289
1289
|
networkStats(ifacesArray.join(',')).then((result) => {
|
|
@@ -1294,7 +1294,7 @@ function networkStats(ifaces, callback) {
|
|
|
1294
1294
|
});
|
|
1295
1295
|
});
|
|
1296
1296
|
} else {
|
|
1297
|
-
for (
|
|
1297
|
+
for (const iface of ifacesArray) {
|
|
1298
1298
|
workload.push(networkStatsSingle(iface.trim()));
|
|
1299
1299
|
}
|
|
1300
1300
|
if (workload.length) {
|
|
@@ -1318,7 +1318,7 @@ function networkStats(ifaces, callback) {
|
|
|
1318
1318
|
function networkStatsSingle(iface) {
|
|
1319
1319
|
function parseLinesWindowsPerfData(sections) {
|
|
1320
1320
|
const perfData = [];
|
|
1321
|
-
for (
|
|
1321
|
+
for (const i in sections) {
|
|
1322
1322
|
if ({}.hasOwnProperty.call(sections, i)) {
|
|
1323
1323
|
if (sections[i].trim() !== '') {
|
|
1324
1324
|
const lines = sections[i].trim().split('\r\n');
|
|
@@ -1595,7 +1595,7 @@ function networkConnections(callback) {
|
|
|
1595
1595
|
'export LC_ALL=C; netstat -na | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN"; unset LC_ALL';
|
|
1596
1596
|
}
|
|
1597
1597
|
exec(cmd, { maxBuffer: 1024 * 102400 }, (error, stdout) => {
|
|
1598
|
-
|
|
1598
|
+
const lines = stdout.toString().split('\n');
|
|
1599
1599
|
if (!error && (lines.length > 1 || lines[0] !== '')) {
|
|
1600
1600
|
lines.forEach((line) => {
|
|
1601
1601
|
line = line.replace(/ +/g, ' ').split(' ');
|
|
@@ -1784,11 +1784,11 @@ function networkConnections(callback) {
|
|
|
1784
1784
|
});
|
|
1785
1785
|
}
|
|
1786
1786
|
if (_windows) {
|
|
1787
|
-
|
|
1787
|
+
const cmd = 'netstat -nao';
|
|
1788
1788
|
try {
|
|
1789
1789
|
exec(cmd, util.execOptsWin, (error, stdout) => {
|
|
1790
1790
|
if (!error) {
|
|
1791
|
-
|
|
1791
|
+
const lines = stdout.toString().split('\r\n');
|
|
1792
1792
|
|
|
1793
1793
|
lines.forEach((line) => {
|
|
1794
1794
|
line = line.trim().replace(/ +/g, ' ').split(' ');
|
|
@@ -1899,7 +1899,7 @@ function networkGatewayDefault(callback) {
|
|
|
1899
1899
|
try {
|
|
1900
1900
|
exec(cmd, { maxBuffer: 1024 * 102400 }, (error, stdout) => {
|
|
1901
1901
|
if (!error) {
|
|
1902
|
-
|
|
1902
|
+
const lines = stdout.toString().split('\n');
|
|
1903
1903
|
const line = lines && lines[0] ? lines[0] : '';
|
|
1904
1904
|
let parts = line.split(' via ');
|
|
1905
1905
|
if (parts && parts[1]) {
|
|
@@ -1979,7 +1979,7 @@ function networkGatewayDefault(callback) {
|
|
|
1979
1979
|
});
|
|
1980
1980
|
if (!result) {
|
|
1981
1981
|
util.powerShell("Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq '0.0.0.0' -and $_.Mask -eq '0.0.0.0' }").then((data) => {
|
|
1982
|
-
|
|
1982
|
+
const lines = data.toString().split('\r\n');
|
|
1983
1983
|
if (lines.length > 1 && !result) {
|
|
1984
1984
|
result = util.getValue(lines, 'NextHop');
|
|
1985
1985
|
if (callback) {
|
package/lib/util.js
CHANGED
|
@@ -2764,35 +2764,45 @@ function checkWebsite(url, timeout = 5000) {
|
|
|
2764
2764
|
const http = url.startsWith('https:') || url.indexOf(':443/') > 0 || url.indexOf(':8443/') > 0 ? require('https') : require('http');
|
|
2765
2765
|
const t = Date.now();
|
|
2766
2766
|
return new Promise((resolve) => {
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2767
|
+
try {
|
|
2768
|
+
const request = http
|
|
2769
|
+
.get(url, (res) => {
|
|
2770
|
+
res.on('data', () => {});
|
|
2771
|
+
res.on('end', () => {
|
|
2772
|
+
resolve({
|
|
2773
|
+
url,
|
|
2774
|
+
statusCode: res.statusCode,
|
|
2775
|
+
message: res.statusMessage,
|
|
2776
|
+
time: Date.now() - t
|
|
2777
|
+
});
|
|
2778
|
+
});
|
|
2779
|
+
})
|
|
2780
|
+
.on('error', (e) => {
|
|
2771
2781
|
resolve({
|
|
2772
2782
|
url,
|
|
2773
|
-
statusCode:
|
|
2774
|
-
message:
|
|
2783
|
+
statusCode: 404,
|
|
2784
|
+
message: e.message,
|
|
2785
|
+
time: Date.now() - t
|
|
2786
|
+
});
|
|
2787
|
+
})
|
|
2788
|
+
.setTimeout(timeout, () => {
|
|
2789
|
+
request.destroy();
|
|
2790
|
+
resolve({
|
|
2791
|
+
url,
|
|
2792
|
+
statusCode: 408,
|
|
2793
|
+
message: 'Request Timeout',
|
|
2775
2794
|
time: Date.now() - t
|
|
2776
2795
|
});
|
|
2777
2796
|
});
|
|
2778
|
-
|
|
2779
|
-
.
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
});
|
|
2786
|
-
})
|
|
2787
|
-
.setTimeout(timeout, () => {
|
|
2788
|
-
request.destroy();
|
|
2789
|
-
resolve({
|
|
2790
|
-
url,
|
|
2791
|
-
statusCode: 408,
|
|
2792
|
-
message: 'Request Timeout',
|
|
2793
|
-
time: Date.now() - t
|
|
2794
|
-
});
|
|
2797
|
+
} catch (e) {
|
|
2798
|
+
// http.get() throws synchronously on invalid URLs
|
|
2799
|
+
resolve({
|
|
2800
|
+
url,
|
|
2801
|
+
statusCode: 404,
|
|
2802
|
+
message: e.message,
|
|
2803
|
+
time: Date.now() - t
|
|
2795
2804
|
});
|
|
2805
|
+
}
|
|
2796
2806
|
});
|
|
2797
2807
|
}
|
|
2798
2808
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.33.
|
|
3
|
+
"version": "5.33.18",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|