systeminformation 5.23.13 → 5.23.15
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/README.md +216 -139
- package/lib/system.js +6 -6
- package/lib/users.js +1 -1
- package/lib/util.js +1161 -0
- package/lib/wifi.js +49 -3
- package/package.json +1 -1
package/lib/wifi.js
CHANGED
|
@@ -396,6 +396,47 @@ function parseWifiDarwin(wifiObj) {
|
|
|
396
396
|
}
|
|
397
397
|
return result;
|
|
398
398
|
}
|
|
399
|
+
|
|
400
|
+
function parseWifi2Darwin(wifiStr) {
|
|
401
|
+
const result = [];
|
|
402
|
+
try {
|
|
403
|
+
let wifiObj = JSON.parse(wifiStr);
|
|
404
|
+
wifiObj = wifiObj.SPAirPortDataType[0].spairport_airport_interfaces[0].spairport_airport_other_local_wireless_networks;
|
|
405
|
+
wifiObj.forEach(function (wifiItem) {
|
|
406
|
+
|
|
407
|
+
let security = [];
|
|
408
|
+
const sm = wifiItem.spairport_security_mode;
|
|
409
|
+
if (sm === 'spairport_security_mode_wep') {
|
|
410
|
+
security.push('WEP');
|
|
411
|
+
} else if (sm === 'spairport_security_mode_wpa2_personal') {
|
|
412
|
+
security.push('WPA2');
|
|
413
|
+
} else if (sm.startsWith('spairport_security_mode_wpa2_enterprise')) {
|
|
414
|
+
security.push('WPA2 EAP');
|
|
415
|
+
} else if (sm.startsWith('pairport_security_mode_wpa3_transition')) {
|
|
416
|
+
security.push('WPA2/WPA3');
|
|
417
|
+
} else if (sm.startsWith('pairport_security_mode_wpa3')) {
|
|
418
|
+
security.push('WPA3');
|
|
419
|
+
}
|
|
420
|
+
const channelInfo = new RegExp(/(\d+) \((\d)GHz, (\d+)MHz\)/g).exec(wifiItem.spairport_network_channel);
|
|
421
|
+
|
|
422
|
+
result.push({
|
|
423
|
+
ssid: wifiItem._name || '',
|
|
424
|
+
bssid: '',
|
|
425
|
+
mode: wifiItem.spairport_network_phymode,
|
|
426
|
+
channel: parseInt(channelInfo[0].split(' ')[0]),
|
|
427
|
+
frequency: wifiFrequencyFromChannel(channelInfo[1]),
|
|
428
|
+
signalLevel: null,
|
|
429
|
+
quality: null,
|
|
430
|
+
security,
|
|
431
|
+
wpaFlags: [],
|
|
432
|
+
rsnFlags: []
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
return result;
|
|
436
|
+
} catch (e) {
|
|
437
|
+
return result;
|
|
438
|
+
}
|
|
439
|
+
};
|
|
399
440
|
function wifiNetworks(callback) {
|
|
400
441
|
return new Promise((resolve) => {
|
|
401
442
|
process.nextTick(() => {
|
|
@@ -459,10 +500,15 @@ function wifiNetworks(callback) {
|
|
|
459
500
|
resolve(result);
|
|
460
501
|
}
|
|
461
502
|
} else if (_darwin) {
|
|
462
|
-
let cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s -x';
|
|
503
|
+
let cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s -x >2 /dev/bull; echo "######"; system_profiler -json SPAirPortDataType';
|
|
463
504
|
exec(cmd, { maxBuffer: 1024 * 40000 }, function (error, stdout) {
|
|
464
505
|
const output = stdout.toString();
|
|
465
|
-
|
|
506
|
+
const parts = output.split('######');
|
|
507
|
+
if (parts[0]) {
|
|
508
|
+
result = parseWifiDarwin(util.plistParser(parts[0]));
|
|
509
|
+
} else {
|
|
510
|
+
result = parseWifi2Darwin(parts[1]);
|
|
511
|
+
}
|
|
466
512
|
if (callback) {
|
|
467
513
|
callback(result);
|
|
468
514
|
}
|
|
@@ -700,7 +746,7 @@ function wifiConnections(callback) {
|
|
|
700
746
|
const model = lines[1].indexOf(':') >= 0 ? lines[1].split(':')[1].trim() : '';
|
|
701
747
|
const id = lines[2].indexOf(':') >= 0 ? lines[2].split(':')[1].trim() : '';
|
|
702
748
|
const ssid = util.getValue(lines, 'SSID', ':', true);
|
|
703
|
-
const bssid = util.getValue(lines, 'BSSID', ':', true) || util.getValue(lines, 'AP BSSID', ':', true)
|
|
749
|
+
const bssid = util.getValue(lines, 'BSSID', ':', true) || util.getValue(lines, 'AP BSSID', ':', true);
|
|
704
750
|
const quality = util.getValue(lines, 'Signal', ':', true);
|
|
705
751
|
const signalLevel = wifiDBFromQuality(quality);
|
|
706
752
|
const type = util.getValue(lines, 'Radio type', ':', true) || util.getValue(lines, 'Type de radio', ':', true) || util.getValue(lines, 'Funktyp', ':', true) || null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.23.
|
|
3
|
+
"version": "5.23.15",
|
|
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)",
|