systeminformation 5.12.10 → 5.12.12

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/index.d.ts CHANGED
@@ -499,8 +499,8 @@ export namespace Systeminformation {
499
499
  operstate: string;
500
500
  type: string;
501
501
  duplex: string;
502
- mtu: number;
503
- speed: number;
502
+ mtu: number | null;
503
+ speed: number | null;
504
504
  dhcp: boolean;
505
505
  dnsSuffix: string;
506
506
  ieee8021xAuth: string;
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/memory.js CHANGED
@@ -245,13 +245,13 @@ function mem(callback) {
245
245
  if (!error) {
246
246
  let lines = stdout.toString().split('\n');
247
247
  if (lines.length > 0) {
248
- let line = lines[0].replace(/,/g, '.').replace(/M/g, '');
249
- line = line.trim().split(' ');
250
- for (let i = 0; i < line.length; i++) {
251
- if (line[i].toLowerCase().indexOf('total') !== -1) { result.swaptotal = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024; }
252
- if (line[i].toLowerCase().indexOf('used') !== -1) { result.swapused = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024; }
253
- if (line[i].toLowerCase().indexOf('free') !== -1) { result.swapfree = parseFloat(line[i].split('=')[1].trim()) * 1024 * 1024; }
254
- }
248
+ let firstline = lines[0].replace(/,/g, '.').replace(/M/g, '');
249
+ let lineArray = firstline.trim().split(' ');
250
+ lineArray.forEach(line => {
251
+ if (line.toLowerCase().indexOf('total') !== -1) { result.swaptotal = parseFloat(line.split('=')[1].trim()) * 1024 * 1024; }
252
+ if (line.toLowerCase().indexOf('used') !== -1) { result.swapused = parseFloat(line.split('=')[1].trim()) * 1024 * 1024; }
253
+ if (line.toLowerCase().indexOf('free') !== -1) { result.swapfree = parseFloat(line.split('=')[1].trim()) * 1024 * 1024; }
254
+ });
255
255
  }
256
256
  }
257
257
  if (callback) { callback(result); }
package/lib/osinfo.js CHANGED
@@ -289,8 +289,6 @@ function osInfo(callback) {
289
289
  result.logofile = getLogoFile(result.distro);
290
290
  result.codename = 'macOS';
291
291
  result.codename = (result.release.indexOf('10.4') > -1 ? 'Mac OS X Tiger' : result.codename);
292
- result.codename = (result.release.indexOf('10.4') > -1 ? 'Mac OS X Tiger' : result.codename);
293
- result.codename = (result.release.indexOf('10.4') > -1 ? 'Mac OS X Tiger' : result.codename);
294
292
  result.codename = (result.release.indexOf('10.5') > -1 ? 'Mac OS X Leopard' : result.codename);
295
293
  result.codename = (result.release.indexOf('10.6') > -1 ? 'Mac OS X Snow Leopard' : result.codename);
296
294
  result.codename = (result.release.indexOf('10.7') > -1 ? 'Mac OS X Lion' : result.codename);
@@ -738,9 +736,9 @@ function versions(apps, callback) {
738
736
  if (_windows) {
739
737
  util.powerShell('Get-WmiObject Win32_Service | select caption | fl').then((stdout) => {
740
738
  let serviceSections = stdout.split(/\n\s*\n/);
741
- for (let i = 0; i < serviceSections.length; i++) {
742
- if (serviceSections[i].trim() !== '') {
743
- let lines = serviceSections[i].trim().split('\r\n');
739
+ serviceSections.forEach((item) => {
740
+ if (item.trim() !== '') {
741
+ let lines = item.trim().split('\r\n');
744
742
  let srvCaption = util.getValue(lines, 'caption', ':', true).toLowerCase();
745
743
  if (srvCaption.indexOf('postgresql') > -1) {
746
744
  const parts = srvCaption.split(' server ');
@@ -749,7 +747,7 @@ function versions(apps, callback) {
749
747
  }
750
748
  }
751
749
  }
752
- }
750
+ });
753
751
  functionProcessed();
754
752
  });
755
753
  } else {
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
- return [];
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
- for (let i = 0; i < iwlistParts.length; i++) {
248
- const lines = iwlistParts[i].split('\n');
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 = iwlistParts[i].indexOf(' WPA ') >= 0;
261
- const isWpa2 = iwlistParts[i].indexOf('WPA2 ') >= 0;
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
- for (let i = 0; i < iwconfigParts.length; i++) {
396
- if (iwconfigParts[i].indexOf('no wireless') === -1 && iwconfigParts[i].trim() !== '') {
397
- iface = iwconfigParts[i].split(' ')[0];
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.10",
3
+ "version": "5.12.12",
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)",