systeminformation 5.12.9 → 5.12.11
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/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/bluetooth.js +62 -16
- package/lib/index.js +0 -9
- package/lib/processes.js +40 -35
- package/lib/usb.js +0 -32
- package/lib/wifi.js +34 -37
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2014-
|
|
3
|
+
Copyright (c) 2014-2022 Sebastian Hildebrandt
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
package/README.md
CHANGED
|
@@ -1024,7 +1024,7 @@ All other trademarks are the property of their respective owners.
|
|
|
1024
1024
|
|
|
1025
1025
|
>The [`MIT`][license-url] License (MIT)
|
|
1026
1026
|
>
|
|
1027
|
-
>Copyright © 2014-
|
|
1027
|
+
>Copyright © 2014-2022 Sebastian Hildebrandt, [+innovations](http://www.plus-innovations.com).
|
|
1028
1028
|
>
|
|
1029
1029
|
>Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1030
1030
|
>of this software and associated documentation files (the "Software"), to deal
|
package/lib/bluetooth.js
CHANGED
|
@@ -37,6 +37,25 @@ function parseBluetoothType(str) {
|
|
|
37
37
|
if (str.indexOf('speaker') >= 0) { result = 'Speaker'; }
|
|
38
38
|
if (str.indexOf('headset') >= 0) { result = 'Headset'; }
|
|
39
39
|
if (str.indexOf('phone') >= 0) { result = 'Phone'; }
|
|
40
|
+
if (str.indexOf('macbook') >= 0) { result = 'Computer'; }
|
|
41
|
+
if (str.indexOf('imac') >= 0) { result = 'Computer'; }
|
|
42
|
+
if (str.indexOf('ipad') >= 0) { result = 'Tablet'; }
|
|
43
|
+
if (str.indexOf('watch') >= 0) { result = 'Watch'; }
|
|
44
|
+
if (str.indexOf('headphone') >= 0) { result = 'Headset'; }
|
|
45
|
+
// to be continued ...
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function parseBluetoothManufacturer(str) {
|
|
51
|
+
let result = str.split(' ')[0];
|
|
52
|
+
str = str.toLowerCase();
|
|
53
|
+
if (str.indexOf('apple') >= 0) { result = 'Apple'; }
|
|
54
|
+
if (str.indexOf('ipad') >= 0) { result = 'Apple'; }
|
|
55
|
+
if (str.indexOf('imac') >= 0) { result = 'Apple'; }
|
|
56
|
+
if (str.indexOf('iphone') >= 0) { result = 'Apple'; }
|
|
57
|
+
if (str.indexOf('magic mouse') >= 0) { result = 'Apple'; }
|
|
58
|
+
if (str.indexOf('macbook') >= 0) { result = 'Apple'; }
|
|
40
59
|
// to be continued ...
|
|
41
60
|
|
|
42
61
|
return result;
|
|
@@ -59,12 +78,12 @@ function parseLinuxBluetoothInfo(lines, macAddr1, macAddr2) {
|
|
|
59
78
|
|
|
60
79
|
function parseDarwinBluetoothDevices(bluetoothObject, macAddr2) {
|
|
61
80
|
const result = {};
|
|
62
|
-
const typeStr = ((bluetoothObject.device_minorClassOfDevice_string || bluetoothObject.device_majorClassOfDevice_string || '') + (bluetoothObject.device_name || '')).toLowerCase();
|
|
81
|
+
const typeStr = ((bluetoothObject.device_minorClassOfDevice_string || bluetoothObject.device_majorClassOfDevice_string || bluetoothObject.device_minorType || '') + (bluetoothObject.device_name || '')).toLowerCase();
|
|
63
82
|
|
|
64
83
|
result.device = bluetoothObject.device_services || '';
|
|
65
84
|
result.name = bluetoothObject.device_name || '';
|
|
66
|
-
result.manufacturer = bluetoothObject.device_manufacturer || '';
|
|
67
|
-
result.macDevice = (bluetoothObject.device_addr || '').toLowerCase().replace(/-/g, ':');
|
|
85
|
+
result.manufacturer = bluetoothObject.device_manufacturer || parseBluetoothManufacturer(bluetoothObject.device_name || '') || '';
|
|
86
|
+
result.macDevice = (bluetoothObject.device_addr || bluetoothObject.device_address || '').toLowerCase().replace(/-/g, ':');
|
|
68
87
|
result.macHost = macAddr2;
|
|
69
88
|
result.batteryPercent = bluetoothObject.device_batteryPercent || null;
|
|
70
89
|
result.type = parseBluetoothType(typeStr);
|
|
@@ -96,16 +115,16 @@ function bluetoothDevices(callback) {
|
|
|
96
115
|
if (_linux) {
|
|
97
116
|
// get files in /var/lib/bluetooth/ recursive
|
|
98
117
|
const btFiles = util.getFilesInPath('/var/lib/bluetooth/');
|
|
99
|
-
|
|
100
|
-
const filename = path.basename(
|
|
101
|
-
const pathParts =
|
|
118
|
+
btFiles.forEach((element) => {
|
|
119
|
+
const filename = path.basename(element);
|
|
120
|
+
const pathParts = element.split('/');
|
|
102
121
|
const macAddr1 = pathParts.length >= 6 ? pathParts[pathParts.length - 2] : null;
|
|
103
122
|
const macAddr2 = pathParts.length >= 7 ? pathParts[pathParts.length - 3] : null;
|
|
104
123
|
if (filename === 'info') {
|
|
105
|
-
const infoFile = fs.readFileSync(
|
|
124
|
+
const infoFile = fs.readFileSync(element, { encoding: 'utf8' }).split('\n');
|
|
106
125
|
result.push(parseLinuxBluetoothInfo(infoFile, macAddr1, macAddr2));
|
|
107
126
|
}
|
|
108
|
-
}
|
|
127
|
+
});
|
|
109
128
|
// determine "connected" with hcitool con
|
|
110
129
|
try {
|
|
111
130
|
const hdicon = execSync('hcitool con').toString().toLowerCase();
|
|
@@ -135,9 +154,8 @@ function bluetoothDevices(callback) {
|
|
|
135
154
|
if (outObj.SPBluetoothDataType[0]['local_device_title'] && outObj.SPBluetoothDataType[0].local_device_title.general_address) {
|
|
136
155
|
macAddr2 = outObj.SPBluetoothDataType[0].local_device_title.general_address.toLowerCase().replace(/-/g, ':');
|
|
137
156
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const obj = outObj.SPBluetoothDataType[0]['device_title'][i];
|
|
157
|
+
outObj.SPBluetoothDataType[0]['device_title'].forEach((element) => {
|
|
158
|
+
const obj = element;
|
|
141
159
|
const objKey = Object.keys(obj);
|
|
142
160
|
if (objKey && objKey.length === 1) {
|
|
143
161
|
const innerObject = obj[objKey[0]];
|
|
@@ -145,7 +163,35 @@ function bluetoothDevices(callback) {
|
|
|
145
163
|
const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
|
|
146
164
|
result.push(bluetoothDevice);
|
|
147
165
|
}
|
|
148
|
-
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (outObj.SPBluetoothDataType && outObj.SPBluetoothDataType.length && outObj.SPBluetoothDataType[0] && outObj.SPBluetoothDataType[0]['device_connected'] && outObj.SPBluetoothDataType[0]['device_connected'].length) {
|
|
169
|
+
const macAddr2 = outObj.SPBluetoothDataType[0].controller_properties && outObj.SPBluetoothDataType[0].controller_properties.controller_address ? outObj.SPBluetoothDataType[0].controller_properties.controller_address.toLowerCase().replace(/-/g, ':') : null;
|
|
170
|
+
outObj.SPBluetoothDataType[0]['device_connected'].forEach((element) => {
|
|
171
|
+
const obj = element;
|
|
172
|
+
const objKey = Object.keys(obj);
|
|
173
|
+
if (objKey && objKey.length === 1) {
|
|
174
|
+
const innerObject = obj[objKey[0]];
|
|
175
|
+
innerObject.device_name = objKey[0];
|
|
176
|
+
innerObject.device_isconnected = 'attrib_Yes';
|
|
177
|
+
const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
|
|
178
|
+
result.push(bluetoothDevice);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (outObj.SPBluetoothDataType && outObj.SPBluetoothDataType.length && outObj.SPBluetoothDataType[0] && outObj.SPBluetoothDataType[0]['device_not_connected'] && outObj.SPBluetoothDataType[0]['device_not_connected'].length) {
|
|
183
|
+
const macAddr2 = outObj.SPBluetoothDataType[0].controller_properties && outObj.SPBluetoothDataType[0].controller_properties.controller_address ? outObj.SPBluetoothDataType[0].controller_properties.controller_address.toLowerCase().replace(/-/g, ':') : null;
|
|
184
|
+
outObj.SPBluetoothDataType[0]['device_not_connected'].forEach((element) => {
|
|
185
|
+
const obj = element;
|
|
186
|
+
const objKey = Object.keys(obj);
|
|
187
|
+
if (objKey && objKey.length === 1) {
|
|
188
|
+
const innerObject = obj[objKey[0]];
|
|
189
|
+
innerObject.device_name = objKey[0];
|
|
190
|
+
innerObject.device_isconnected = 'attrib_No';
|
|
191
|
+
const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
|
|
192
|
+
result.push(bluetoothDevice);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
149
195
|
}
|
|
150
196
|
} catch (e) {
|
|
151
197
|
util.noop();
|
|
@@ -161,11 +207,11 @@ function bluetoothDevices(callback) {
|
|
|
161
207
|
util.powerShell('Get-WmiObject Win32_PNPEntity | select PNPClass, Name, Manufacturer | fl').then((stdout, error) => {
|
|
162
208
|
if (!error) {
|
|
163
209
|
const parts = stdout.toString().split(/\n\s*\n/);
|
|
164
|
-
|
|
165
|
-
if (util.getValue(
|
|
166
|
-
result.push(parseWindowsBluetooth(
|
|
210
|
+
parts.forEach((part) => {
|
|
211
|
+
if (util.getValue(part.split('\n'), 'PNPClass', ':') === 'Bluetooth') {
|
|
212
|
+
result.push(parseWindowsBluetooth(part.split('\n')));
|
|
167
213
|
}
|
|
168
|
-
}
|
|
214
|
+
});
|
|
169
215
|
}
|
|
170
216
|
if (callback) {
|
|
171
217
|
callback(result);
|
package/lib/index.js
CHANGED
|
@@ -159,14 +159,6 @@ function getDynamicData(srv, iface, callback) {
|
|
|
159
159
|
};
|
|
160
160
|
})();
|
|
161
161
|
|
|
162
|
-
// var totalFunctions = 14;
|
|
163
|
-
// function functionProcessed() {
|
|
164
|
-
// if (--totalFunctions === 0) {
|
|
165
|
-
// if (callback) { callback(data) }
|
|
166
|
-
// resolve(data);
|
|
167
|
-
// }
|
|
168
|
-
// }
|
|
169
|
-
|
|
170
162
|
let data = {};
|
|
171
163
|
|
|
172
164
|
// get time
|
|
@@ -342,7 +334,6 @@ function get(valueObject, callback) {
|
|
|
342
334
|
result[key] = data[i];
|
|
343
335
|
} else {
|
|
344
336
|
let keys = valueObject[key];
|
|
345
|
-
// let params = '';
|
|
346
337
|
let filter = '';
|
|
347
338
|
let filterParts = [];
|
|
348
339
|
// remove params
|
package/lib/processes.js
CHANGED
|
@@ -253,8 +253,8 @@ function services(srv, callback) {
|
|
|
253
253
|
// process
|
|
254
254
|
let list_new = {};
|
|
255
255
|
let resultProcess = {};
|
|
256
|
-
|
|
257
|
-
resultProcess = calcProcStatLinux(
|
|
256
|
+
curr_processes.forEach((element) => {
|
|
257
|
+
resultProcess = calcProcStatLinux(element, all, _services_cpu);
|
|
258
258
|
|
|
259
259
|
if (resultProcess.pid) {
|
|
260
260
|
let listPos = -1;
|
|
@@ -279,7 +279,7 @@ function services(srv, callback) {
|
|
|
279
279
|
cstime: resultProcess.cstime
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
|
-
}
|
|
282
|
+
});
|
|
283
283
|
|
|
284
284
|
// store old values
|
|
285
285
|
_services_cpu.all = all;
|
|
@@ -338,18 +338,18 @@ function services(srv, callback) {
|
|
|
338
338
|
let wincommand = 'Get-WmiObject Win32_Service';
|
|
339
339
|
if (srvs[0] !== '*') {
|
|
340
340
|
wincommand += ' -Filter "';
|
|
341
|
-
|
|
342
|
-
wincommand += `Name='${
|
|
343
|
-
}
|
|
341
|
+
srvs.forEach((srv) => {
|
|
342
|
+
wincommand += `Name='${srv}' or `;
|
|
343
|
+
});
|
|
344
344
|
wincommand = `${wincommand.slice(0, -4)}"`;
|
|
345
345
|
}
|
|
346
346
|
wincommand += ' | select Name,Caption,Started,StartMode,ProcessId | fl';
|
|
347
347
|
util.powerShell(wincommand).then((stdout, error) => {
|
|
348
348
|
if (!error) {
|
|
349
349
|
let serviceSections = stdout.split(/\n\s*\n/);
|
|
350
|
-
|
|
351
|
-
if (
|
|
352
|
-
let lines =
|
|
350
|
+
serviceSections.forEach((element) => {
|
|
351
|
+
if (element.trim() !== '') {
|
|
352
|
+
let lines = element.trim().split('\r\n');
|
|
353
353
|
let srvName = util.getValue(lines, 'Name', ':', true).toLowerCase();
|
|
354
354
|
let srvCaption = util.getValue(lines, 'Caption', ':', true).toLowerCase();
|
|
355
355
|
let started = util.getValue(lines, 'Started', ':', true);
|
|
@@ -368,7 +368,9 @@ function services(srv, callback) {
|
|
|
368
368
|
dataSrv.push(srvCaption);
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
|
|
371
|
+
|
|
372
|
+
});
|
|
373
|
+
|
|
372
374
|
if (srvString !== '*') {
|
|
373
375
|
let srvsMissing = srvs.filter(function (e) {
|
|
374
376
|
return dataSrv.indexOf(e) === -1;
|
|
@@ -740,9 +742,9 @@ function processes(callback) {
|
|
|
740
742
|
if (_linux) {
|
|
741
743
|
// calc process_cpu - ps is not accurate in linux!
|
|
742
744
|
cmd = 'cat /proc/stat | grep "cpu "';
|
|
743
|
-
|
|
744
|
-
cmd += (';cat /proc/' +
|
|
745
|
-
}
|
|
745
|
+
result.list.forEach((element) => {
|
|
746
|
+
cmd += (';cat /proc/' + element.pid + '/stat');
|
|
747
|
+
});
|
|
746
748
|
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
|
|
747
749
|
let curr_processes = stdout.toString().split('\n');
|
|
748
750
|
|
|
@@ -752,8 +754,8 @@ function processes(callback) {
|
|
|
752
754
|
// process
|
|
753
755
|
let list_new = {};
|
|
754
756
|
let resultProcess = {};
|
|
755
|
-
|
|
756
|
-
resultProcess = calcProcStatLinux(
|
|
757
|
+
curr_processes.forEach((element) => {
|
|
758
|
+
resultProcess = calcProcStatLinux(element, all, _processes_cpu);
|
|
757
759
|
|
|
758
760
|
if (resultProcess.pid) {
|
|
759
761
|
|
|
@@ -775,7 +777,7 @@ function processes(callback) {
|
|
|
775
777
|
cstime: resultProcess.cstime
|
|
776
778
|
};
|
|
777
779
|
}
|
|
778
|
-
}
|
|
780
|
+
});
|
|
779
781
|
|
|
780
782
|
// store old values
|
|
781
783
|
_processes_cpu.all = all;
|
|
@@ -829,9 +831,9 @@ function processes(callback) {
|
|
|
829
831
|
let list_new = {};
|
|
830
832
|
let allcpuu = 0;
|
|
831
833
|
let allcpus = 0;
|
|
832
|
-
|
|
833
|
-
if (
|
|
834
|
-
let lines =
|
|
834
|
+
processSections.forEach((element) => {
|
|
835
|
+
if (element.trim() !== '') {
|
|
836
|
+
let lines = element.trim().split('\r\n');
|
|
835
837
|
let pid = parseInt(util.getValue(lines, 'ProcessId', ':', true), 10);
|
|
836
838
|
let parentPid = parseInt(util.getValue(lines, 'ParentProcessId', ':', true), 10);
|
|
837
839
|
let statusValue = util.getValue(lines, 'ExecutionState', ':');
|
|
@@ -889,11 +891,12 @@ function processes(callback) {
|
|
|
889
891
|
params: ''
|
|
890
892
|
});
|
|
891
893
|
}
|
|
892
|
-
}
|
|
894
|
+
});
|
|
895
|
+
|
|
893
896
|
result.sleeping = result.all - result.running - result.blocked - result.unknown;
|
|
894
897
|
result.list = procs;
|
|
895
|
-
|
|
896
|
-
let resultProcess = calcProcStatWin(
|
|
898
|
+
procStats.forEach((element) => {
|
|
899
|
+
let resultProcess = calcProcStatWin(element, allcpuu + allcpus, _processes_cpu);
|
|
897
900
|
|
|
898
901
|
// store pcpu in outer array
|
|
899
902
|
let listPos = result.list.map(function (e) { return e.pid; }).indexOf(resultProcess.pid);
|
|
@@ -910,7 +913,8 @@ function processes(callback) {
|
|
|
910
913
|
utime: resultProcess.utime,
|
|
911
914
|
stime: resultProcess.stime
|
|
912
915
|
};
|
|
913
|
-
}
|
|
916
|
+
});
|
|
917
|
+
|
|
914
918
|
// store old values
|
|
915
919
|
_processes_cpu.all = allcpuu + allcpus;
|
|
916
920
|
_processes_cpu.all_utime = allcpuu;
|
|
@@ -972,7 +976,7 @@ function processLoad(proc, callback) {
|
|
|
972
976
|
|
|
973
977
|
const s = util.sanitizeShellString(proc);
|
|
974
978
|
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
|
|
975
|
-
if (
|
|
979
|
+
if (s[i] !== undefined) {
|
|
976
980
|
processesString = processesString + s[i];
|
|
977
981
|
}
|
|
978
982
|
}
|
|
@@ -1008,9 +1012,9 @@ function processLoad(proc, callback) {
|
|
|
1008
1012
|
let allcpus = 0;
|
|
1009
1013
|
|
|
1010
1014
|
// go through all processes
|
|
1011
|
-
|
|
1012
|
-
if (
|
|
1013
|
-
let lines =
|
|
1015
|
+
processSections.forEach((element) => {
|
|
1016
|
+
if (element.trim() !== '') {
|
|
1017
|
+
let lines = element.trim().split('\r\n');
|
|
1014
1018
|
let pid = parseInt(util.getValue(lines, 'ProcessId', ':', true), 10);
|
|
1015
1019
|
let name = util.getValue(lines, 'Caption', ':', true);
|
|
1016
1020
|
let utime = parseInt(util.getValue(lines, 'UserModeTime', ':', true), 10);
|
|
@@ -1058,7 +1062,8 @@ function processLoad(proc, callback) {
|
|
|
1058
1062
|
}
|
|
1059
1063
|
}
|
|
1060
1064
|
}
|
|
1061
|
-
}
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1062
1067
|
// add missing processes
|
|
1063
1068
|
if (processesString !== '*') {
|
|
1064
1069
|
let processesMissing = processes.filter(function (name) {
|
|
@@ -1077,8 +1082,8 @@ function processLoad(proc, callback) {
|
|
|
1077
1082
|
}
|
|
1078
1083
|
|
|
1079
1084
|
// calculate proc stats for each proc
|
|
1080
|
-
|
|
1081
|
-
let resultProcess = calcProcStatWin(
|
|
1085
|
+
procStats.forEach((element) => {
|
|
1086
|
+
let resultProcess = calcProcStatWin(element, allcpuu + allcpus, _process_cpu);
|
|
1082
1087
|
|
|
1083
1088
|
let listPos = -1;
|
|
1084
1089
|
for (let j = 0; j < result.length; j++) {
|
|
@@ -1095,7 +1100,8 @@ function processLoad(proc, callback) {
|
|
|
1095
1100
|
utime: resultProcess.utime,
|
|
1096
1101
|
stime: resultProcess.stime
|
|
1097
1102
|
};
|
|
1098
|
-
}
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1099
1105
|
// store old values
|
|
1100
1106
|
_process_cpu.all = allcpuu + allcpus;
|
|
1101
1107
|
_process_cpu.all_utime = allcpuu;
|
|
@@ -1210,9 +1216,8 @@ function processLoad(proc, callback) {
|
|
|
1210
1216
|
// process
|
|
1211
1217
|
let list_new = {};
|
|
1212
1218
|
let resultProcess = {};
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
resultProcess = calcProcStatLinux(curr_processes[i], all, _process_cpu);
|
|
1219
|
+
curr_processes.forEach((element) => {
|
|
1220
|
+
resultProcess = calcProcStatLinux(element, all, _process_cpu);
|
|
1216
1221
|
|
|
1217
1222
|
if (resultProcess.pid) {
|
|
1218
1223
|
|
|
@@ -1238,7 +1243,7 @@ function processLoad(proc, callback) {
|
|
|
1238
1243
|
cstime: resultProcess.cstime
|
|
1239
1244
|
};
|
|
1240
1245
|
}
|
|
1241
|
-
}
|
|
1246
|
+
});
|
|
1242
1247
|
|
|
1243
1248
|
result.forEach(function (item) {
|
|
1244
1249
|
item.cpu = Math.round(item.cpu * 100) / 100;
|
package/lib/usb.js
CHANGED
|
@@ -14,9 +14,7 @@
|
|
|
14
14
|
// ----------------------------------------------------------------------------------
|
|
15
15
|
|
|
16
16
|
const exec = require('child_process').exec;
|
|
17
|
-
// const execSync = require('child_process').execSync;
|
|
18
17
|
const util = require('./util');
|
|
19
|
-
// const fs = require('fs');
|
|
20
18
|
|
|
21
19
|
let _platform = process.platform;
|
|
22
20
|
|
|
@@ -91,16 +89,6 @@ function parseLinuxUsb(usb) {
|
|
|
91
89
|
return result;
|
|
92
90
|
}
|
|
93
91
|
|
|
94
|
-
// bus
|
|
95
|
-
// deviceId
|
|
96
|
-
// id
|
|
97
|
-
// name(product)
|
|
98
|
-
// type(bInterfaceClass)
|
|
99
|
-
// removable / hotplug
|
|
100
|
-
// vendor
|
|
101
|
-
// manufacturer
|
|
102
|
-
// maxpower(linux)
|
|
103
|
-
|
|
104
92
|
function getDarwinUsbType(name) {
|
|
105
93
|
let result = '';
|
|
106
94
|
if (name.indexOf('camera') >= 0) { result = 'Camera'; }
|
|
@@ -164,25 +152,6 @@ function parseDarwinUsb(usb, id) {
|
|
|
164
152
|
}
|
|
165
153
|
}
|
|
166
154
|
|
|
167
|
-
// function getWindowsUsbType(service) {
|
|
168
|
-
// let result = ''
|
|
169
|
-
// if (service.indexOf('usbhub3') >= 0) { result = 'Hub'; }
|
|
170
|
-
// else if (service.indexOf('usbstor') >= 0) { result = 'Storage'; }
|
|
171
|
-
// else if (service.indexOf('hidusb') >= 0) { result = 'Input'; }
|
|
172
|
-
// else if (service.indexOf('usbccgp') >= 0) { result = 'Controller'; }
|
|
173
|
-
// else if (service.indexOf('usbxhci') >= 0) { result = 'Controller'; }
|
|
174
|
-
// else if (service.indexOf('usbehci') >= 0) { result = 'Controller'; }
|
|
175
|
-
// else if (service.indexOf('kbdhid') >= 0) { result = 'Keyboard'; }
|
|
176
|
-
// else if (service.indexOf('keyboard') >= 0) { result = 'Keyboard'; }
|
|
177
|
-
// else if (service.indexOf('pointing') >= 0) { result = 'Mouse'; }
|
|
178
|
-
// else if (service.indexOf('disk') >= 0) { result = 'Storage'; }
|
|
179
|
-
// else if (service.indexOf('usbhub') >= 0) { result = 'Hub'; }
|
|
180
|
-
// else if (service.indexOf('bthusb') >= 0) { result = ''; }
|
|
181
|
-
// else if (service.indexOf('bth') >= 0) { result = ''; }
|
|
182
|
-
// else if (service.indexOf('rfcomm') >= 0) { result = ''; }
|
|
183
|
-
// return result;
|
|
184
|
-
// }
|
|
185
|
-
|
|
186
155
|
function getWindowsUsbTypeCreation(creationclass, name) {
|
|
187
156
|
let result = '';
|
|
188
157
|
if (name.indexOf('storage') >= 0) { result = 'Storage'; }
|
|
@@ -216,7 +185,6 @@ function parseWindowsUsb(lines, id) {
|
|
|
216
185
|
} else {
|
|
217
186
|
return null;
|
|
218
187
|
}
|
|
219
|
-
|
|
220
188
|
}
|
|
221
189
|
|
|
222
190
|
function usb(callback) {
|
package/lib/wifi.js
CHANGED
|
@@ -125,7 +125,7 @@ function wifiChannelFromFrequencs(frequency) {
|
|
|
125
125
|
|
|
126
126
|
function ifaceListLinux() {
|
|
127
127
|
const result = [];
|
|
128
|
-
const cmd = 'iw dev';
|
|
128
|
+
const cmd = 'iw dev 2>/dev/null';
|
|
129
129
|
try {
|
|
130
130
|
const all = execSync(cmd).toString().split('\n').map(line => line.trim()).join('\n');
|
|
131
131
|
const parts = all.split('\nInterface ');
|
|
@@ -145,7 +145,30 @@ function ifaceListLinux() {
|
|
|
145
145
|
});
|
|
146
146
|
return result;
|
|
147
147
|
} catch (e) {
|
|
148
|
-
|
|
148
|
+
try {
|
|
149
|
+
const all = execSync('nmcli -t -f general,wifi-properties,wired-properties,interface-flags,capabilities,nsp device show 2>/dev/null').toString();
|
|
150
|
+
const parts = all.split('\nGENERAL.DEVICE:');
|
|
151
|
+
let i = 1;
|
|
152
|
+
parts.forEach(ifaceDetails => {
|
|
153
|
+
const lines = ifaceDetails.split('\n');
|
|
154
|
+
const iface = util.getValue(lines, 'GENERAL.DEVICE');
|
|
155
|
+
const type = util.getValue(lines, 'GENERAL.TYPE');
|
|
156
|
+
const id = i++; // // util.getValue(lines, 'GENERAL.PATH');
|
|
157
|
+
const mac = util.getValue(lines, 'GENERAL.HWADDR');
|
|
158
|
+
const channel = '';
|
|
159
|
+
if (type.toLowerCase() === 'wifi') {
|
|
160
|
+
result.push({
|
|
161
|
+
id,
|
|
162
|
+
iface,
|
|
163
|
+
mac,
|
|
164
|
+
channel
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return result;
|
|
169
|
+
} catch (e) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
149
172
|
}
|
|
150
173
|
}
|
|
151
174
|
|
|
@@ -244,8 +267,8 @@ function getWifiNetworkListIw(iface) {
|
|
|
244
267
|
if (iwlistParts[0].indexOf('resource busy') >= 0) { return -1; }
|
|
245
268
|
if (iwlistParts.length > 1) {
|
|
246
269
|
iwlistParts.shift();
|
|
247
|
-
|
|
248
|
-
const lines =
|
|
270
|
+
iwlistParts.forEach(element => {
|
|
271
|
+
const lines = element.split('\n');
|
|
249
272
|
const channel = util.getValue(lines, 'channel', ':', true);
|
|
250
273
|
const address = (lines && lines.length && lines[0].indexOf('Address:') >= 0 ? lines[0].split('Address:')[1].trim().toLowerCase() : '');
|
|
251
274
|
const mode = util.getValue(lines, 'mode', ':', true);
|
|
@@ -257,8 +280,8 @@ function getWifiNetworkListIw(iface) {
|
|
|
257
280
|
const ssid = util.getValue(lines, 'essid', ':', true);
|
|
258
281
|
|
|
259
282
|
// security and wpa-flags
|
|
260
|
-
const isWpa =
|
|
261
|
-
const isWpa2 =
|
|
283
|
+
const isWpa = element.indexOf(' WPA ') >= 0;
|
|
284
|
+
const isWpa2 = element.indexOf('WPA2 ') >= 0;
|
|
262
285
|
const security = [];
|
|
263
286
|
if (isWpa) { security.push('WPA'); }
|
|
264
287
|
if (isWpa2) { security.push('WPA2'); }
|
|
@@ -307,7 +330,7 @@ function getWifiNetworkListIw(iface) {
|
|
|
307
330
|
wpaFlags,
|
|
308
331
|
rsnFlags: []
|
|
309
332
|
});
|
|
310
|
-
}
|
|
333
|
+
});
|
|
311
334
|
}
|
|
312
335
|
return result;
|
|
313
336
|
} catch (e) {
|
|
@@ -315,30 +338,6 @@ function getWifiNetworkListIw(iface) {
|
|
|
315
338
|
}
|
|
316
339
|
}
|
|
317
340
|
|
|
318
|
-
/*
|
|
319
|
-
ssid: line.substring(parsedhead[0].from, parsedhead[0].to).trim(),
|
|
320
|
-
bssid: line.substring(parsedhead[1].from, parsedhead[1].to).trim().toLowerCase(),
|
|
321
|
-
mode: '',
|
|
322
|
-
channel,
|
|
323
|
-
frequency: wifiFrequencyFromChannel(channel),
|
|
324
|
-
signalLevel: signalLevel ? parseInt(signalLevel, 10) : null,
|
|
325
|
-
quality: wifiQualityFromDB(signalLevel),
|
|
326
|
-
security,
|
|
327
|
-
wpaFlags,
|
|
328
|
-
rsnFlags: []
|
|
329
|
-
|
|
330
|
-
const securityAll = line.substring(parsedhead[6].from, 1000).trim().split(' ');
|
|
331
|
-
let security = [];
|
|
332
|
-
let wpaFlags = [];
|
|
333
|
-
securityAll.forEach(securitySingle => {
|
|
334
|
-
if (securitySingle.indexOf('(') > 0) {
|
|
335
|
-
const parts = securitySingle.split('(');
|
|
336
|
-
security.push(parts[0]);
|
|
337
|
-
wpaFlags = wpaFlags.concat(parts[1].replace(')', '').split(','));
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
*/
|
|
342
341
|
function parseWifiDarwin(wifiObj) {
|
|
343
342
|
const result = [];
|
|
344
343
|
if (wifiObj) {
|
|
@@ -392,11 +391,11 @@ function wifiNetworks(callback) {
|
|
|
392
391
|
try {
|
|
393
392
|
const iwconfigParts = execSync('export LC_ALL=C; iwconfig 2>/dev/null; unset LC_ALL').toString().split('\n\n');
|
|
394
393
|
let iface = '';
|
|
395
|
-
|
|
396
|
-
if (
|
|
397
|
-
iface =
|
|
394
|
+
iwconfigParts.forEach(element => {
|
|
395
|
+
if (element.indexOf('no wireless') === -1 && element.trim() !== '') {
|
|
396
|
+
iface = element.split(' ')[0];
|
|
398
397
|
}
|
|
399
|
-
}
|
|
398
|
+
});
|
|
400
399
|
if (iface) {
|
|
401
400
|
const res = getWifiNetworkListIw(iface);
|
|
402
401
|
if (res === -1) {
|
|
@@ -574,7 +573,6 @@ function wifiConnections(callback) {
|
|
|
574
573
|
const rssi = util.toInt(util.getValue(lines2, 'agrCtlRSSI', ':', true));
|
|
575
574
|
const noise = util.toInt(util.getValue(lines2, 'agrCtlNoise', ':', true));
|
|
576
575
|
const signalLevel = rssi - noise;
|
|
577
|
-
// const signal = wifiQualityFromDB(signalLevel);
|
|
578
576
|
if (ssid || bssid) {
|
|
579
577
|
result.push({
|
|
580
578
|
id: 'Wi-Fi',
|
|
@@ -589,7 +587,6 @@ function wifiConnections(callback) {
|
|
|
589
587
|
signalLevel,
|
|
590
588
|
txRate
|
|
591
589
|
});
|
|
592
|
-
|
|
593
590
|
}
|
|
594
591
|
}
|
|
595
592
|
if (callback) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.11",
|
|
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)",
|