systeminformation 5.23.15 → 5.23.17

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 CHANGED
@@ -1417,9 +1417,10 @@ function getProcessName(processes, pid) {
1417
1417
  }
1418
1418
  });
1419
1419
  cmd = cmd.split(' -')[0];
1420
- // return cmd;
1421
- const cmdParts = cmd.split('/');
1422
- return cmdParts[cmdParts.length - 1];
1420
+ cmd = cmd.split(' /')[0];
1421
+ return cmd;
1422
+ // const cmdParts = cmd.split('/');
1423
+ // return cmdParts[cmdParts.length - 1];
1423
1424
  }
1424
1425
 
1425
1426
  function networkConnections(callback) {
@@ -1534,19 +1535,19 @@ function networkConnections(callback) {
1534
1535
  });
1535
1536
  }
1536
1537
  if (_darwin) {
1537
- let cmd = 'netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6"';
1538
- const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT_1|FIN_WAIT2|FIN_WAIT_2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN';
1538
+ let cmd = 'netstat -natvln | head -n2; netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6"';
1539
+ const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT_1|FIN_WAIT2|FIN_WAIT_2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN'.split('|');
1539
1540
  exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
1540
1541
  if (!error) {
1541
1542
  exec('ps -axo pid,command', { maxBuffer: 1024 * 20000 }, function (err2, stdout2) {
1542
1543
  let processes = stdout2.toString().split('\n');
1543
1544
  processes = processes.map((line => { return line.trim().replace(/ +/g, ' '); }));
1544
1545
  let lines = stdout.toString().split('\n');
1545
-
1546
-
1546
+ lines.shift();
1547
+ const header = lines.shift().replace(/ Address/g, '_Address').replace(/ +/g, ' ').split(' ');
1548
+ let pidPos = header.indexOf('pid');
1547
1549
  lines.forEach(function (line) {
1548
1550
  line = line.replace(/ +/g, ' ').split(' ');
1549
- const hasTransferred = line.length >= 19;
1550
1551
  if (line.length >= 8) {
1551
1552
  let localip = line[3];
1552
1553
  let localport = '';
@@ -1566,7 +1567,7 @@ function networkConnections(callback) {
1566
1567
  }
1567
1568
  const hasState = states.indexOf(line[5]) >= 0;
1568
1569
  let connstate = hasState ? line[5] : 'UNKNOWN';
1569
- let pid = parseInt(line[8 + (hasState ? 0 : -1) + (hasTransferred ? 2 : 0)], 10);
1570
+ let pid = parseInt(line[pidPos + (hasState ? 0 : -1)], 10);
1570
1571
  if (connstate) {
1571
1572
  result.push({
1572
1573
  protocol: line[0],
package/lib/wifi.js CHANGED
@@ -176,7 +176,7 @@ function ifaceListLinux() {
176
176
  }
177
177
 
178
178
  function nmiDeviceLinux(iface) {
179
- const cmd = `nmcli -t -f general,wifi-properties,capabilities,ip4,ip6 device show ${iface} 2>/dev/null`;
179
+ const cmd = `nmcli -t -f general,wifi-properties,capabilities,ip4,ip6 device show ${iface} 2> /dev/null`;
180
180
  try {
181
181
  const lines = execSync(cmd, util.execOptsLinux).toString().split('\n');
182
182
  const ssid = util.getValue(lines, 'GENERAL.CONNECTION');
@@ -345,7 +345,7 @@ function getWifiNetworkListIw(iface) {
345
345
  }
346
346
  }
347
347
 
348
- function parseWifiDarwin(wifiObj) {
348
+ function parseWifiDarwinXX(wifiObj) {
349
349
  const result = [];
350
350
  if (wifiObj) {
351
351
  wifiObj.forEach(function (wifiItem) {
@@ -397,7 +397,7 @@ function parseWifiDarwin(wifiObj) {
397
397
  return result;
398
398
  }
399
399
 
400
- function parseWifi2Darwin(wifiStr) {
400
+ function parseWifiDarwin(wifiStr) {
401
401
  const result = [];
402
402
  try {
403
403
  let wifiObj = JSON.parse(wifiStr);
@@ -417,16 +417,17 @@ function parseWifi2Darwin(wifiStr) {
417
417
  } else if (sm.startsWith('pairport_security_mode_wpa3')) {
418
418
  security.push('WPA3');
419
419
  }
420
- const channelInfo = new RegExp(/(\d+) \((\d)GHz, (\d+)MHz\)/g).exec(wifiItem.spairport_network_channel);
420
+ const channel = parseInt(('' + wifiItem.spairport_network_channel).split(' ')[0]) || 0;
421
+ const signalLevel = wifiItem.spairport_signal_noise || null;
421
422
 
422
423
  result.push({
423
424
  ssid: wifiItem._name || '',
424
- bssid: '',
425
+ bssid: wifiItem.spairport_network_bssid || null,
425
426
  mode: wifiItem.spairport_network_phymode,
426
- channel: parseInt(channelInfo[0].split(' ')[0]),
427
- frequency: wifiFrequencyFromChannel(channelInfo[1]),
428
- signalLevel: null,
429
- quality: null,
427
+ channel,
428
+ frequency: wifiFrequencyFromChannel(channel),
429
+ signalLevel: signalLevel ? parseInt(signalLevel, 10) : null,
430
+ quality: wifiQualityFromDB(signalLevel),
430
431
  security,
431
432
  wpaFlags: [],
432
433
  rsnFlags: []
@@ -500,15 +501,9 @@ function wifiNetworks(callback) {
500
501
  resolve(result);
501
502
  }
502
503
  } else if (_darwin) {
503
- let cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s -x >2 /dev/bull; echo "######"; system_profiler -json SPAirPortDataType';
504
+ let cmd = 'system_profiler SPAirPortDataType -json 2>/dev/null';
504
505
  exec(cmd, { maxBuffer: 1024 * 40000 }, function (error, stdout) {
505
- const output = stdout.toString();
506
- const parts = output.split('######');
507
- if (parts[0]) {
508
- result = parseWifiDarwin(util.plistParser(parts[0]));
509
- } else {
510
- result = parseWifi2Darwin(parts[1]);
511
- }
506
+ result = parseWifiDarwin(stdout.toString());
512
507
  if (callback) {
513
508
  callback(result);
514
509
  }
@@ -650,85 +645,62 @@ function wifiConnections(callback) {
650
645
  }
651
646
  resolve(result);
652
647
  } else if (_darwin) {
653
- let cmd = 'system_profiler SPNetworkDataType';
648
+ let cmd = 'system_profiler SPNetworkDataType SPAirPortDataType -xml 2>/dev/null; echo "######" ; ioreg -n AppleBCMWLANSkywalkInterface -r 2>/dev/null';
654
649
  exec(cmd, function (error, stdout) {
655
- const parts1 = stdout.toString().split('\n\n Wi-Fi:\n\n');
656
- if (parts1.length > 1) {
657
- const lines = parts1[1].split('\n\n')[0].split('\n');
658
- const iface = util.getValue(lines, 'BSD Device Name', ':', true);
659
- const model = util.getValue(lines, 'hardware', ':', true);
660
- cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I 2>/dev/null; echo "######" ; ioreg -n AppleBCMWLANSkywalkInterface -r 2>/dev/null';
661
- exec(cmd, function (error, stdout) {
662
- const parts = stdout.toString().split('######');
663
- const lines2 = parts[0].split('\n');
664
- let lines3 = [];
665
- if (parts[1].indexOf(' | {') > 0 && parts[1].indexOf(' | }') > parts[1].indexOf(' | {')) {
666
- lines3 = parts[1].split(' | {')[1].split(' | }')[0].replace(/ \| /g, '').replace(/"/g, '').split('\n');
667
- }
668
- if (lines2.length > 10) {
669
- const ssid = util.getValue(lines2, 'ssid', ':', true);
670
- const bssid = util.getValue(lines2, 'bssid', ':', true) || formatBssid(util.getValue(lines3, 'IO80211BSSID', '=', true));
671
- const security = util.getValue(lines2, 'link auth', ':', true);
672
- const txRate = util.getValue(lines2, 'lastTxRate', ':', true);
673
- const channel = util.getValue(lines2, 'channel', ':', true).split(',')[0];
674
- const type = '802.11';
675
- const rssi = util.toInt(util.getValue(lines2, 'agrCtlRSSI', ':', true));
676
- /// const noise = util.toInt(util.getValue(lines2, 'agrCtlNoise', ':', true));
677
- const signalLevel = rssi;
678
- if (ssid || bssid) {
679
- result.push({
680
- id: 'Wi-Fi',
681
- iface,
682
- model,
683
- ssid,
684
- bssid,
685
- channel: util.toInt(channel),
686
- frequency: channel ? wifiFrequencyFromChannel(channel) : null,
687
- type,
688
- security,
689
- signalLevel,
690
- quality: wifiQualityFromDB(signalLevel),
691
- txRate
692
- });
693
- }
694
- }
695
- if (lines3.length > 10) {
696
- const ssid = util.getValue(lines3, 'IO80211SSID', '=', true);
697
- const bssid = formatBssid(util.getValue(lines3, 'IO80211BSSID', '=', true));
698
- const security = '';
699
- const txRate = -1;
700
- const signalLevel = -1;
701
- const quality = -1;
702
- const channel = util.getValue(lines3, 'IO80211Channel', '=', true);
703
- const type = '802.11';
704
- if ((ssid || bssid) && !result.length) {
705
- result.push({
706
- id: 'Wi-Fi',
707
- iface,
708
- model,
709
- ssid,
710
- bssid,
711
- channel: util.toInt(channel),
712
- frequency: channel ? wifiFrequencyFromChannel(channel) : null,
713
- type,
714
- security,
715
- signalLevel,
716
- quality,
717
- txRate
718
- });
719
- }
720
- }
721
- if (callback) {
722
- callback(result);
723
- }
724
- resolve(result);
725
- });
726
- } else {
727
- if (callback) {
728
- callback(result);
650
+ try {
651
+ const parts = stdout.toString().split('######');
652
+ const profilerObj = util.plistParser(parts[0]);
653
+ const networkObj = profilerObj[0]._SPCommandLineArguments.indexOf('SPNetworkDataType') >= 0 ? profilerObj[0]._items : profilerObj[1]._items;
654
+ const airportObj = profilerObj[0]._SPCommandLineArguments.indexOf('SPAirPortDataType') >= 0 ? profilerObj[0]._items[0].spairport_airport_interfaces : profilerObj[1]._items[0].spairport_airport_interfaces;
655
+
656
+ // parts[1] : ioreg
657
+ let lines3 = [];
658
+ if (parts[1].indexOf(' | {') > 0 && parts[1].indexOf(' | }') > parts[1].indexOf(' | {')) {
659
+ lines3 = parts[1].split(' | {')[1].split(' | }')[0].replace(/ \| /g, '').replace(/"/g, '').split('\n');
729
660
  }
730
- resolve(result);
661
+
662
+ const networkWifiObj = networkObj.find((item) => { return item._name === 'Wi-Fi'; });
663
+ const airportWifiObj = airportObj[0].spairport_current_network_information;
664
+
665
+ const channel = parseInt(('' + airportWifiObj.spairport_network_channel).split(' ')[0]) || 0;
666
+ const signalLevel = airportWifiObj.spairport_signal_noise || null;
667
+
668
+ let security = [];
669
+ const sm = airportWifiObj.spairport_security_mode;
670
+ if (sm === 'spairport_security_mode_wep') {
671
+ security.push('WEP');
672
+ } else if (sm === 'spairport_security_mode_wpa2_personal') {
673
+ security.push('WPA2');
674
+ } else if (sm.startsWith('spairport_security_mode_wpa2_enterprise')) {
675
+ security.push('WPA2 EAP');
676
+ } else if (sm.startsWith('pairport_security_mode_wpa3_transition')) {
677
+ security.push('WPA2/WPA3');
678
+ } else if (sm.startsWith('pairport_security_mode_wpa3')) {
679
+ security.push('WPA3');
680
+ }
681
+
682
+ result.push({
683
+ id: networkWifiObj._name || 'Wi-Fi',
684
+ iface: networkWifiObj.interface || '',
685
+ model: networkWifiObj.hardware || '',
686
+ ssid: airportWifiObj._name || '',
687
+ bssid: airportWifiObj.spairport_network_bssid || '',
688
+ channel,
689
+ frequency: channel ? wifiFrequencyFromChannel(channel) : null,
690
+ type: airportWifiObj.spairport_network_phymode || '802.11',
691
+ security,
692
+ signalLevel: signalLevel ? parseInt(signalLevel, 10) : null,
693
+ quality: wifiQualityFromDB(signalLevel),
694
+ txRate: airportWifiObj.spairport_network_rate || null,
695
+ });
696
+
697
+ } catch (e) {
698
+ util.noop();
731
699
  }
700
+ if (callback) {
701
+ callback(result);
702
+ }
703
+ resolve(result);
732
704
  });
733
705
  } else if (_windows) {
734
706
  let cmd = 'netsh wlan show interfaces';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.23.15",
3
+ "version": "5.23.17",
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)",