systeminformation 5.31.5 → 5.31.7
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/network.js +25 -55
- package/lib/osinfo.js +7 -0
- package/lib/util.js +27 -0
- package/lib/wifi.js +6 -27
- package/package.json +1 -1
package/lib/network.js
CHANGED
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
const os = require('os');
|
|
17
17
|
const exec = require('child_process').exec;
|
|
18
18
|
const execSync = require('child_process').execSync;
|
|
19
|
+
const execFileSync = require('child_process').execFileSync;
|
|
20
|
+
const readFileSync = require('fs').readFileSync;
|
|
21
|
+
|
|
19
22
|
const fs = require('fs');
|
|
20
23
|
const util = require('./util');
|
|
21
24
|
|
|
@@ -416,15 +419,7 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) {
|
|
|
416
419
|
try {
|
|
417
420
|
const SSID = getWindowsWirelessIfaceSSID(iface);
|
|
418
421
|
if (SSID !== 'Unknown') {
|
|
419
|
-
|
|
420
|
-
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(SSID);
|
|
421
|
-
const l = util.mathMin(s.length, 32);
|
|
422
|
-
|
|
423
|
-
for (let i = 0; i <= l; i++) {
|
|
424
|
-
if (s[i] !== undefined) {
|
|
425
|
-
ifaceSanitized = ifaceSanitized + s[i];
|
|
426
|
-
}
|
|
427
|
-
}
|
|
422
|
+
const ifaceSanitized = util.sanitizeString(SSID);
|
|
428
423
|
const profiles = execSync(`netsh wlan show profiles "${ifaceSanitized}"`, util.execOptsWin).split('\r\n');
|
|
429
424
|
i8021xState = (profiles.find((l) => l.indexOf('802.1X') >= 0) || '').trim();
|
|
430
425
|
i8021xProtocol = (profiles.find((l) => l.indexOf('EAP') >= 0) || '').trim();
|
|
@@ -536,14 +531,16 @@ function getDarwinNics() {
|
|
|
536
531
|
}
|
|
537
532
|
|
|
538
533
|
function getLinuxIfaceConnectionName(interfaceName) {
|
|
539
|
-
const cmd = `nmcli device status 2>/dev/null | grep ${interfaceName}`;
|
|
540
|
-
|
|
541
534
|
try {
|
|
542
|
-
const
|
|
535
|
+
const output = execFileSync('nmcli', ['device', 'status'], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
536
|
+
const result = util.grep(output, interfaceName);
|
|
537
|
+
|
|
543
538
|
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
|
544
539
|
const connectionNameLines = resultFormat.split(' ').slice(3);
|
|
545
540
|
const connectionName = connectionNameLines.join(' ');
|
|
546
|
-
|
|
541
|
+
const connectionNameSanitized = util.sanitizeString(connectionName, false);
|
|
542
|
+
|
|
543
|
+
return connectionNameSanitized !== '--' ? connectionNameSanitized : '';
|
|
547
544
|
} catch {
|
|
548
545
|
return '';
|
|
549
546
|
}
|
|
@@ -552,8 +549,8 @@ function getLinuxIfaceConnectionName(interfaceName) {
|
|
|
552
549
|
function checkLinuxDCHPInterfaces(file) {
|
|
553
550
|
let result = [];
|
|
554
551
|
try {
|
|
555
|
-
const
|
|
556
|
-
const lines =
|
|
552
|
+
const content = readFileSync(file, { encoding: 'utf8' });
|
|
553
|
+
const lines = content.split('\n').filter((l) => /iface|source/.test(l));
|
|
557
554
|
|
|
558
555
|
lines.forEach((line) => {
|
|
559
556
|
const parts = line.replace(/\s+/g, ' ').trim().split(' ');
|
|
@@ -617,9 +614,9 @@ function parseLinuxDHCPNics(sections) {
|
|
|
617
614
|
function getLinuxIfaceDHCPstatus(iface, connectionName, DHCPNics) {
|
|
618
615
|
let result = false;
|
|
619
616
|
if (connectionName) {
|
|
620
|
-
const cmd = `nmcli connection show "${connectionName}" 2>/dev/null | grep ipv4.method;`;
|
|
621
617
|
try {
|
|
622
|
-
const
|
|
618
|
+
const output = execFileSync('nmcli', ['connection', 'show', connectionName], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
619
|
+
const lines = util.grep(output, 'ipv4.method');
|
|
623
620
|
const resultFormat = lines.replace(/\s+/g, ' ').trim();
|
|
624
621
|
|
|
625
622
|
const dhcStatus = resultFormat.split(' ').slice(1).toString();
|
|
@@ -643,9 +640,10 @@ function getLinuxIfaceDHCPstatus(iface, connectionName, DHCPNics) {
|
|
|
643
640
|
|
|
644
641
|
function getDarwinIfaceDHCPstatus(iface) {
|
|
645
642
|
let result = false;
|
|
646
|
-
|
|
643
|
+
|
|
647
644
|
try {
|
|
648
|
-
const
|
|
645
|
+
const output = execFileSync('ipconfig', ['getpacket', iface], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
646
|
+
const lines = util.grep(output, 'lease_time');
|
|
649
647
|
if (lines.length && lines[0].startsWith('lease_time')) {
|
|
650
648
|
result = true;
|
|
651
649
|
}
|
|
@@ -657,9 +655,9 @@ function getDarwinIfaceDHCPstatus(iface) {
|
|
|
657
655
|
|
|
658
656
|
function getLinuxIfaceDNSsuffix(connectionName) {
|
|
659
657
|
if (connectionName) {
|
|
660
|
-
const cmd = `nmcli connection show "${connectionName}" 2>/dev/null | grep ipv4.dns-search;`;
|
|
661
658
|
try {
|
|
662
|
-
const
|
|
659
|
+
const output = execFileSync('nmcli', ['connection', 'show', connectionName], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
660
|
+
const result = util.grep(output, 'ipv4.dns-search');
|
|
663
661
|
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
|
664
662
|
const dnsSuffix = resultFormat.split(' ').slice(1).toString();
|
|
665
663
|
return dnsSuffix === '--' ? 'Not defined' : dnsSuffix;
|
|
@@ -673,9 +671,9 @@ function getLinuxIfaceDNSsuffix(connectionName) {
|
|
|
673
671
|
|
|
674
672
|
function getLinuxIfaceIEEE8021xAuth(connectionName) {
|
|
675
673
|
if (connectionName) {
|
|
676
|
-
const cmd = `nmcli connection show "${connectionName}" 2>/dev/null | grep 802-1x.eap;`;
|
|
677
674
|
try {
|
|
678
|
-
const
|
|
675
|
+
const output = execFileSync('nmcli', ['connection', 'show', connectionName], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
|
|
676
|
+
const result = util.grep(output, '802-1x.eap');
|
|
679
677
|
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
|
680
678
|
const authenticationProtocol = resultFormat.split(' ').slice(1).toString();
|
|
681
679
|
|
|
@@ -825,14 +823,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|
|
825
823
|
nic.ip6subnet = ip6linksubnet;
|
|
826
824
|
}
|
|
827
825
|
|
|
828
|
-
|
|
829
|
-
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(nic.iface);
|
|
830
|
-
const l = util.mathMin(s.length, 2000);
|
|
831
|
-
for (let i = 0; i <= l; i++) {
|
|
832
|
-
if (s[i] !== undefined) {
|
|
833
|
-
ifaceSanitized = ifaceSanitized + s[i];
|
|
834
|
-
}
|
|
835
|
-
}
|
|
826
|
+
const ifaceSanitized = util.sanitizeString(nic.iface);
|
|
836
827
|
|
|
837
828
|
result.push({
|
|
838
829
|
iface: nic.iface,
|
|
@@ -948,14 +939,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|
|
948
939
|
ip6subnet = ip6linksubnet;
|
|
949
940
|
}
|
|
950
941
|
const iface = dev.split(':')[0].trim();
|
|
951
|
-
|
|
952
|
-
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
|
|
953
|
-
const l = util.mathMin(s.length, 2000);
|
|
954
|
-
for (let i = 0; i <= l; i++) {
|
|
955
|
-
if (s[i] !== undefined) {
|
|
956
|
-
ifaceSanitized = ifaceSanitized + s[i];
|
|
957
|
-
}
|
|
958
|
-
}
|
|
942
|
+
const ifaceSanitized = util.sanitizeString(iface);
|
|
959
943
|
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${ifaceSanitized}/addr_assign_type 2>/dev/null; echo;
|
|
960
944
|
echo -n "address: "; cat /sys/class/net/${ifaceSanitized}/address 2>/dev/null; echo;
|
|
961
945
|
echo -n "addr_len: "; cat /sys/class/net/${ifaceSanitized}/addr_len 2>/dev/null; echo;
|
|
@@ -1087,14 +1071,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|
|
1087
1071
|
nics8021xInfo = getWindowsWiredProfilesInformation();
|
|
1088
1072
|
dnsSuffixes = getWindowsDNSsuffixes();
|
|
1089
1073
|
for (let dev in ifaces) {
|
|
1090
|
-
|
|
1091
|
-
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(dev);
|
|
1092
|
-
const l = util.mathMin(s.length, 2000);
|
|
1093
|
-
for (let i = 0; i <= l; i++) {
|
|
1094
|
-
if (s[i] !== undefined) {
|
|
1095
|
-
ifaceSanitized = ifaceSanitized + s[i];
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1074
|
+
const ifaceSanitized = util.sanitizeString(dev);
|
|
1098
1075
|
|
|
1099
1076
|
let iface = dev;
|
|
1100
1077
|
let ip4 = '';
|
|
@@ -1360,14 +1337,7 @@ function networkStatsSingle(iface) {
|
|
|
1360
1337
|
|
|
1361
1338
|
return new Promise((resolve) => {
|
|
1362
1339
|
process.nextTick(() => {
|
|
1363
|
-
|
|
1364
|
-
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
|
|
1365
|
-
const l = util.mathMin(s.length, 2000);
|
|
1366
|
-
for (let i = 0; i <= l; i++) {
|
|
1367
|
-
if (s[i] !== undefined) {
|
|
1368
|
-
ifaceSanitized = ifaceSanitized + s[i];
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1340
|
+
const ifaceSanitized = util.sanitizeString(iface);
|
|
1371
1341
|
|
|
1372
1342
|
let result = {
|
|
1373
1343
|
iface: ifaceSanitized,
|
package/lib/osinfo.js
CHANGED
|
@@ -18,6 +18,7 @@ const fs = require('fs');
|
|
|
18
18
|
const util = require('./util');
|
|
19
19
|
const exec = require('child_process').exec;
|
|
20
20
|
const execSync = require('child_process').execSync;
|
|
21
|
+
const execFile = require('child_process').execFile;
|
|
21
22
|
|
|
22
23
|
const _platform = process.platform;
|
|
23
24
|
|
|
@@ -820,11 +821,17 @@ function versions(apps, callback) {
|
|
|
820
821
|
if (!error) {
|
|
821
822
|
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
|
822
823
|
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
824
|
+
if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
|
|
825
|
+
appsObj.versions.postgresql = postgresql[postgresql.length - 2];
|
|
826
|
+
}
|
|
823
827
|
} else {
|
|
824
828
|
exec('pg_config --version', (error, stdout) => {
|
|
825
829
|
if (!error) {
|
|
826
830
|
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
|
827
831
|
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
832
|
+
if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
|
|
833
|
+
appsObj.versions.postgresql = postgresql[postgresql.length - 2];
|
|
834
|
+
}
|
|
828
835
|
}
|
|
829
836
|
});
|
|
830
837
|
}
|
package/lib/util.js
CHANGED
|
@@ -830,6 +830,22 @@ function isPrototypePolluted() {
|
|
|
830
830
|
return !notPolluted;
|
|
831
831
|
}
|
|
832
832
|
|
|
833
|
+
function sanitizeString(str, strict) {
|
|
834
|
+
if (typeof strict === 'undefined') {
|
|
835
|
+
strict = false;
|
|
836
|
+
}
|
|
837
|
+
let result = '';
|
|
838
|
+
const s = isPrototypePolluted() ? '---' : sanitizeShellString(str, strict);
|
|
839
|
+
const l = mathMin(s.length, 2000);
|
|
840
|
+
|
|
841
|
+
for (let i = 0; i <= l; i++) {
|
|
842
|
+
if (s[i] !== undefined) {
|
|
843
|
+
result = result + s[i];
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return result;
|
|
847
|
+
}
|
|
848
|
+
|
|
833
849
|
function hex2bin(hex) {
|
|
834
850
|
return ('00000000' + parseInt(hex, 16).toString(2)).substr(-8);
|
|
835
851
|
}
|
|
@@ -2702,6 +2718,15 @@ function checkWebsite(url, timeout = 5000) {
|
|
|
2702
2718
|
function cleanString(str) {
|
|
2703
2719
|
return str.replace(/To Be Filled By O.E.M./g, '');
|
|
2704
2720
|
}
|
|
2721
|
+
|
|
2722
|
+
function grep(str, pattern) {
|
|
2723
|
+
const result = str
|
|
2724
|
+
.split('\n')
|
|
2725
|
+
.filter((line) => line.includes(pattern))
|
|
2726
|
+
.join('\n');
|
|
2727
|
+
return result;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2705
2730
|
function noop() {}
|
|
2706
2731
|
|
|
2707
2732
|
exports.toInt = toInt;
|
|
@@ -2733,6 +2758,7 @@ exports.isRaspberry = isRaspberry;
|
|
|
2733
2758
|
exports.isRaspbian = isRaspbian;
|
|
2734
2759
|
exports.sanitizeShellString = sanitizeShellString;
|
|
2735
2760
|
exports.isPrototypePolluted = isPrototypePolluted;
|
|
2761
|
+
exports.sanitizeString = sanitizeString;
|
|
2736
2762
|
exports.decodePiCpuinfo = decodePiCpuinfo;
|
|
2737
2763
|
exports.getRpiGpu = getRpiGpu;
|
|
2738
2764
|
exports.promiseAll = promiseAll;
|
|
@@ -2757,4 +2783,5 @@ exports.semverCompare = semverCompare;
|
|
|
2757
2783
|
exports.getAppleModel = getAppleModel;
|
|
2758
2784
|
exports.checkWebsite = checkWebsite;
|
|
2759
2785
|
exports.cleanString = cleanString;
|
|
2786
|
+
exports.grep = grep;
|
|
2760
2787
|
exports.getPowershell = getPowershell;
|
package/lib/wifi.js
CHANGED
|
@@ -424,15 +424,7 @@ function wifiNetworks(callback) {
|
|
|
424
424
|
}
|
|
425
425
|
});
|
|
426
426
|
if (iface) {
|
|
427
|
-
|
|
428
|
-
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface, true);
|
|
429
|
-
const l = util.mathMin(s.length, 2000);
|
|
430
|
-
|
|
431
|
-
for (let i = 0; i <= l; i++) {
|
|
432
|
-
if (s[i] !== undefined) {
|
|
433
|
-
ifaceSanitized = ifaceSanitized + s[i];
|
|
434
|
-
}
|
|
435
|
-
}
|
|
427
|
+
const ifaceSanitized = util.sanitizeString(iface, true);
|
|
436
428
|
|
|
437
429
|
const res = getWifiNetworkListIw(ifaceSanitized);
|
|
438
430
|
if (res === -1) {
|
|
@@ -585,28 +577,13 @@ function wifiConnections(callback) {
|
|
|
585
577
|
const ifaces = ifaceListLinux();
|
|
586
578
|
const networkList = getWifiNetworkListNmi();
|
|
587
579
|
ifaces.forEach((ifaceDetail) => {
|
|
588
|
-
|
|
589
|
-
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ifaceDetail.iface, true);
|
|
590
|
-
const ll = util.mathMin(s.length, 2000);
|
|
591
|
-
|
|
592
|
-
for (let i = 0; i <= ll; i++) {
|
|
593
|
-
if (s[i] !== undefined) {
|
|
594
|
-
ifaceSanitized = ifaceSanitized + s[i];
|
|
595
|
-
}
|
|
596
|
-
}
|
|
580
|
+
const ifaceSanitized = util.sanitizeString(ifaceDetail.iface, true);
|
|
597
581
|
|
|
598
582
|
const nmiDetails = nmiDeviceLinux(ifaceSanitized);
|
|
599
583
|
const wpaDetails = wpaConnectionLinux(ifaceSanitized);
|
|
600
584
|
const ssid = nmiDetails.ssid || wpaDetails.ssid;
|
|
601
585
|
const network = networkList.filter((nw) => nw.ssid === ssid);
|
|
602
|
-
|
|
603
|
-
const t = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ssid, true);
|
|
604
|
-
const l = util.mathMin(t.length, 32);
|
|
605
|
-
for (let i = 0; i <= l; i++) {
|
|
606
|
-
if (t[i] !== undefined) {
|
|
607
|
-
ssidSanitized = ssidSanitized + t[i];
|
|
608
|
-
}
|
|
609
|
-
}
|
|
586
|
+
const ssidSanitized = util.sanitizeString(ssid, true);
|
|
610
587
|
|
|
611
588
|
const nmiConnection = nmiConnectionLinux(ssidSanitized);
|
|
612
589
|
const channel = network && network.length && network[0].channel ? network[0].channel : wpaDetails.channel ? wpaDetails.channel : null;
|
|
@@ -760,7 +737,9 @@ function wifiInterfaces(callback) {
|
|
|
760
737
|
if (_linux) {
|
|
761
738
|
const ifaces = ifaceListLinux();
|
|
762
739
|
ifaces.forEach((ifaceDetail) => {
|
|
763
|
-
const
|
|
740
|
+
const ifaceSanitized = util.sanitizeString(ifaceDetail.iface, true);
|
|
741
|
+
|
|
742
|
+
const nmiDetails = nmiDeviceLinux(ifaceSanitized);
|
|
764
743
|
result.push({
|
|
765
744
|
id: ifaceDetail.id,
|
|
766
745
|
iface: ifaceDetail.iface,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.31.
|
|
3
|
+
"version": "5.31.7",
|
|
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)",
|