systeminformation 5.23.14 → 5.23.16

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 CHANGED
@@ -51,7 +51,7 @@
51
51
 
52
52
  I wish you all a Merry Christmas and a peaceful New Year 2025.
53
53
 
54
- This is amazing. Started as a small project just for myself, it now has > 15,000
54
+ This is amazing. Started as a small project just for myself, it now has > 17,000
55
55
  lines of code, > 650 versions published, up to 8 mio downloads per month, > 330
56
56
  mio downloads overall. #1 NPM ranking for backend packages. Thank you to all who
57
57
  contributed to this project!
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) {
@@ -1535,18 +1536,24 @@ function networkConnections(callback) {
1535
1536
  }
1536
1537
  if (_darwin) {
1537
1538
  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';
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
+ let pidPos = 8;
1547
+ if (lines[0] !== '') {
1548
+ const lineParts = lines[0].replace(/ +/g, ' ').split(' ');
1549
+ for (let i = 0; i < lineParts.length; i++) {
1550
+ if (states.indexOf(lineParts[i]) >= 0) {
1551
+ pidPos = i + 3;
1552
+ }
1553
+ };
1554
+ }
1547
1555
  lines.forEach(function (line) {
1548
1556
  line = line.replace(/ +/g, ' ').split(' ');
1549
- const hasTransferred = line.length >= 19;
1550
1557
  if (line.length >= 8) {
1551
1558
  let localip = line[3];
1552
1559
  let localport = '';
@@ -1566,7 +1573,7 @@ function networkConnections(callback) {
1566
1573
  }
1567
1574
  const hasState = states.indexOf(line[5]) >= 0;
1568
1575
  let connstate = hasState ? line[5] : 'UNKNOWN';
1569
- let pid = parseInt(line[8 + (hasState ? 0 : -1) + (hasTransferred ? 2 : 0)], 10);
1576
+ let pid = parseInt(line[pidPos + (hasState ? 0 : -1)], 10);
1570
1577
  if (connstate) {
1571
1578
  result.push({
1572
1579
  protocol: line[0],
package/lib/users.js CHANGED
@@ -120,7 +120,7 @@ function parseUsersDarwin(lines) {
120
120
  result_w.command = l.slice(5, 1000).join(' ');
121
121
  // find corresponding 'who' line
122
122
  who_line = result_who.filter(function (obj) {
123
- return (obj.user === result_w.user && (obj.tty.substring(3, 1000) === result_w.tty || obj.tty === result_w.tty));
123
+ return (obj.user.substring(0, 10) === result_w.user.substring(0, 10) && (obj.tty.substring(3, 1000) === result_w.tty || obj.tty === result_w.tty));
124
124
  });
125
125
  if (who_line.length === 1) {
126
126
  result.push({
package/lib/wifi.js CHANGED
@@ -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) {
@@ -396,6 +396,48 @@ function parseWifiDarwin(wifiObj) {
396
396
  }
397
397
  return result;
398
398
  }
399
+
400
+ function parseWifiDarwin(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 channel = parseInt(('' + wifiItem.spairport_network_channel).split(' ')[0]) || 0;
421
+ const signalLevel = wifiItem.spairport_signal_noise || null;
422
+
423
+ result.push({
424
+ ssid: wifiItem._name || '',
425
+ bssid: wifiItem.spairport_network_bssid || null,
426
+ mode: wifiItem.spairport_network_phymode,
427
+ channel,
428
+ frequency: wifiFrequencyFromChannel(channel),
429
+ signalLevel: signalLevel ? parseInt(signalLevel, 10) : null,
430
+ quality: wifiQualityFromDB(signalLevel),
431
+ security,
432
+ wpaFlags: [],
433
+ rsnFlags: []
434
+ });
435
+ });
436
+ return result;
437
+ } catch (e) {
438
+ return result;
439
+ }
440
+ };
399
441
  function wifiNetworks(callback) {
400
442
  return new Promise((resolve) => {
401
443
  process.nextTick(() => {
@@ -459,10 +501,9 @@ function wifiNetworks(callback) {
459
501
  resolve(result);
460
502
  }
461
503
  } else if (_darwin) {
462
- let cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s -x';
504
+ let cmd = 'system_profiler SPAirPortDataType -json 2>/dev/null';
463
505
  exec(cmd, { maxBuffer: 1024 * 40000 }, function (error, stdout) {
464
- const output = stdout.toString();
465
- result = parseWifiDarwin(util.plistParser(output));
506
+ result = parseWifiDarwin(stdout.toString());
466
507
  if (callback) {
467
508
  callback(result);
468
509
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.23.14",
3
+ "version": "5.23.16",
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)",