systeminformation 5.27.16 → 5.28.0
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 +2 -1
- package/lib/cpu.js +232 -39
- package/lib/graphics.js +348 -241
- package/lib/network.js +1 -1
- package/lib/system.js +246 -143
- package/lib/util.js +52 -51
- package/lib/wifi.js +120 -129
- package/package.json +1 -1
package/lib/wifi.js
CHANGED
|
@@ -20,15 +20,19 @@ const util = require('./util');
|
|
|
20
20
|
|
|
21
21
|
let _platform = process.platform;
|
|
22
22
|
|
|
23
|
-
const _linux =
|
|
24
|
-
const _darwin =
|
|
25
|
-
const _windows =
|
|
23
|
+
const _linux = _platform === 'linux' || _platform === 'android';
|
|
24
|
+
const _darwin = _platform === 'darwin';
|
|
25
|
+
const _windows = _platform === 'win32';
|
|
26
26
|
|
|
27
27
|
function wifiDBFromQuality(quality) {
|
|
28
28
|
const qual = parseFloat(quality);
|
|
29
|
-
if (qual < 0) {
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (qual < 0) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
if (qual >= 100) {
|
|
33
|
+
return -50;
|
|
34
|
+
}
|
|
35
|
+
return qual / 2 - 100;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
function wifiQualityFromDB(db) {
|
|
@@ -120,7 +124,9 @@ function wifiChannelFromFrequencs(frequency) {
|
|
|
120
124
|
let channel = 0;
|
|
121
125
|
for (let key in _wifi_frequencies) {
|
|
122
126
|
if ({}.hasOwnProperty.call(_wifi_frequencies, key)) {
|
|
123
|
-
if (_wifi_frequencies[key] === frequency) {
|
|
127
|
+
if (_wifi_frequencies[key] === frequency) {
|
|
128
|
+
channel = util.toInt(key);
|
|
129
|
+
}
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
132
|
return channel;
|
|
@@ -130,10 +136,14 @@ function ifaceListLinux() {
|
|
|
130
136
|
const result = [];
|
|
131
137
|
const cmd = 'iw dev 2>/dev/null';
|
|
132
138
|
try {
|
|
133
|
-
const all = execSync(cmd, util.execOptsLinux)
|
|
139
|
+
const all = execSync(cmd, util.execOptsLinux)
|
|
140
|
+
.toString()
|
|
141
|
+
.split('\n')
|
|
142
|
+
.map((line) => line.trim())
|
|
143
|
+
.join('\n');
|
|
134
144
|
const parts = all.split('\nInterface ');
|
|
135
145
|
parts.shift();
|
|
136
|
-
parts.forEach(ifaceDetails => {
|
|
146
|
+
parts.forEach((ifaceDetails) => {
|
|
137
147
|
const lines = ifaceDetails.split('\n');
|
|
138
148
|
const iface = lines[0];
|
|
139
149
|
const id = util.toInt(util.getValue(lines, 'ifindex', ' '));
|
|
@@ -152,7 +162,7 @@ function ifaceListLinux() {
|
|
|
152
162
|
const all = execSync('nmcli -t -f general,wifi-properties,wired-properties,interface-flags,capabilities,nsp device show 2>/dev/null', util.execOptsLinux).toString();
|
|
153
163
|
const parts = all.split('\n\n');
|
|
154
164
|
let i = 1;
|
|
155
|
-
parts.forEach(ifaceDetails => {
|
|
165
|
+
parts.forEach((ifaceDetails) => {
|
|
156
166
|
const lines = ifaceDetails.split('\n');
|
|
157
167
|
const iface = util.getValue(lines, 'GENERAL.DEVICE');
|
|
158
168
|
const type = util.getValue(lines, 'GENERAL.TYPE');
|
|
@@ -239,7 +249,7 @@ function getWifiNetworkListNmi() {
|
|
|
239
249
|
const stdout = execSync(cmd, util.execOptsLinux);
|
|
240
250
|
const parts = stdout.toString().split('ACTIVE:');
|
|
241
251
|
parts.shift();
|
|
242
|
-
parts.forEach(part => {
|
|
252
|
+
parts.forEach((part) => {
|
|
243
253
|
part = 'ACTIVE:' + part;
|
|
244
254
|
const lines = part.split(os.EOL);
|
|
245
255
|
const channel = util.getValue(lines, 'CHAN');
|
|
@@ -271,13 +281,15 @@ function getWifiNetworkListIw(iface) {
|
|
|
271
281
|
const result = [];
|
|
272
282
|
try {
|
|
273
283
|
let iwlistParts = execSync(`export LC_ALL=C; iwlist ${iface} scan 2>&1; unset LC_ALL`, util.execOptsLinux).toString().split(' Cell ');
|
|
274
|
-
if (iwlistParts[0].indexOf('resource busy') >= 0) {
|
|
284
|
+
if (iwlistParts[0].indexOf('resource busy') >= 0) {
|
|
285
|
+
return -1;
|
|
286
|
+
}
|
|
275
287
|
if (iwlistParts.length > 1) {
|
|
276
288
|
iwlistParts.shift();
|
|
277
|
-
iwlistParts.forEach(element => {
|
|
289
|
+
iwlistParts.forEach((element) => {
|
|
278
290
|
const lines = element.split('\n');
|
|
279
291
|
const channel = util.getValue(lines, 'channel', ':', true);
|
|
280
|
-
const address =
|
|
292
|
+
const address = lines && lines.length && lines[0].indexOf('Address:') >= 0 ? lines[0].split('Address:')[1].trim().toLowerCase() : '';
|
|
281
293
|
const mode = util.getValue(lines, 'mode', ':', true);
|
|
282
294
|
const frequency = util.getValue(lines, 'frequency', ':', true);
|
|
283
295
|
const qualityString = util.getValue(lines, 'Quality', '=', true);
|
|
@@ -290,11 +302,15 @@ function getWifiNetworkListIw(iface) {
|
|
|
290
302
|
const isWpa = element.indexOf(' WPA ') >= 0;
|
|
291
303
|
const isWpa2 = element.indexOf('WPA2 ') >= 0;
|
|
292
304
|
const security = [];
|
|
293
|
-
if (isWpa) {
|
|
294
|
-
|
|
305
|
+
if (isWpa) {
|
|
306
|
+
security.push('WPA');
|
|
307
|
+
}
|
|
308
|
+
if (isWpa2) {
|
|
309
|
+
security.push('WPA2');
|
|
310
|
+
}
|
|
295
311
|
const wpaFlags = [];
|
|
296
312
|
let wpaFlag = '';
|
|
297
|
-
lines.forEach(
|
|
313
|
+
lines.forEach((line) => {
|
|
298
314
|
const l = line.trim().toLowerCase();
|
|
299
315
|
if (l.indexOf('group cipher') >= 0) {
|
|
300
316
|
if (wpaFlag) {
|
|
@@ -308,16 +324,23 @@ function getWifiNetworkListIw(iface) {
|
|
|
308
324
|
if (l.indexOf('pairwise cipher') >= 0) {
|
|
309
325
|
const parts = l.split(':');
|
|
310
326
|
if (parts.length > 1) {
|
|
311
|
-
if (parts[1].indexOf('tkip')) {
|
|
312
|
-
|
|
313
|
-
else if (parts[1].indexOf('
|
|
327
|
+
if (parts[1].indexOf('tkip')) {
|
|
328
|
+
wpaFlag = wpaFlag ? 'TKIP/' + wpaFlag : 'TKIP';
|
|
329
|
+
} else if (parts[1].indexOf('ccmp')) {
|
|
330
|
+
wpaFlag = wpaFlag ? 'CCMP/' + wpaFlag : 'CCMP';
|
|
331
|
+
} else if (parts[1].indexOf('proprietary')) {
|
|
332
|
+
wpaFlag = wpaFlag ? 'PROP/' + wpaFlag : 'PROP';
|
|
333
|
+
}
|
|
314
334
|
}
|
|
315
335
|
}
|
|
316
336
|
if (l.indexOf('authentication suites') >= 0) {
|
|
317
337
|
const parts = l.split(':');
|
|
318
338
|
if (parts.length > 1) {
|
|
319
|
-
if (parts[1].indexOf('802.1x')) {
|
|
320
|
-
|
|
339
|
+
if (parts[1].indexOf('802.1x')) {
|
|
340
|
+
wpaFlag = wpaFlag ? '802.1x/' + wpaFlag : '802.1x';
|
|
341
|
+
} else if (parts[1].indexOf('psk')) {
|
|
342
|
+
wpaFlag = wpaFlag ? 'PSK/' + wpaFlag : 'PSK';
|
|
343
|
+
}
|
|
321
344
|
}
|
|
322
345
|
}
|
|
323
346
|
});
|
|
@@ -345,66 +368,13 @@ function getWifiNetworkListIw(iface) {
|
|
|
345
368
|
}
|
|
346
369
|
}
|
|
347
370
|
|
|
348
|
-
function parseWifiDarwinXX(wifiObj) {
|
|
349
|
-
const result = [];
|
|
350
|
-
if (wifiObj) {
|
|
351
|
-
wifiObj.forEach(function (wifiItem) {
|
|
352
|
-
const signalLevel = wifiItem.RSSI;
|
|
353
|
-
let security = [];
|
|
354
|
-
let wpaFlags = [];
|
|
355
|
-
let ssid = wifiItem.SSID_STR || '';
|
|
356
|
-
if (wifiItem.WPA_IE) {
|
|
357
|
-
security.push('WPA');
|
|
358
|
-
if (wifiItem.WPA_IE.IE_KEY_WPA_UCIPHERS) {
|
|
359
|
-
wifiItem.WPA_IE.IE_KEY_WPA_UCIPHERS.forEach(function (ciphers) {
|
|
360
|
-
if (ciphers === 0 && wpaFlags.indexOf('unknown/TKIP') === -1) { wpaFlags.push('unknown/TKIP'); }
|
|
361
|
-
if (ciphers === 2 && wpaFlags.indexOf('PSK/TKIP') === -1) { wpaFlags.push('PSK/TKIP'); }
|
|
362
|
-
if (ciphers === 4 && wpaFlags.indexOf('PSK/AES') === -1) { wpaFlags.push('PSK/AES'); }
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
if (wifiItem.RSN_IE) {
|
|
367
|
-
security.push('WPA2');
|
|
368
|
-
if (wifiItem.RSN_IE.IE_KEY_RSN_UCIPHERS) {
|
|
369
|
-
wifiItem.RSN_IE.IE_KEY_RSN_UCIPHERS.forEach(function (ciphers) {
|
|
370
|
-
if (ciphers === 0 && wpaFlags.indexOf('unknown/TKIP') === -1) { wpaFlags.push('unknown/TKIP'); }
|
|
371
|
-
if (ciphers === 2 && wpaFlags.indexOf('TKIP/TKIP') === -1) { wpaFlags.push('TKIP/TKIP'); }
|
|
372
|
-
if (ciphers === 4 && wpaFlags.indexOf('PSK/AES') === -1) { wpaFlags.push('PSK/AES'); }
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
if (wifiItem.SSID && ssid === '') {
|
|
377
|
-
try {
|
|
378
|
-
ssid = Buffer.from(wifiItem.SSID, 'base64').toString('utf8');
|
|
379
|
-
} catch (err) {
|
|
380
|
-
util.noop();
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
result.push({
|
|
384
|
-
ssid,
|
|
385
|
-
bssid: wifiItem.BSSID || '',
|
|
386
|
-
mode: '',
|
|
387
|
-
channel: wifiItem.CHANNEL,
|
|
388
|
-
frequency: wifiFrequencyFromChannel(wifiItem.CHANNEL),
|
|
389
|
-
signalLevel: signalLevel ? parseInt(signalLevel, 10) : null,
|
|
390
|
-
quality: wifiQualityFromDB(signalLevel),
|
|
391
|
-
security,
|
|
392
|
-
wpaFlags,
|
|
393
|
-
rsnFlags: []
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
return result;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
371
|
function parseWifiDarwin(wifiStr) {
|
|
401
372
|
const result = [];
|
|
402
373
|
try {
|
|
403
374
|
let wifiObj = JSON.parse(wifiStr);
|
|
404
375
|
wifiObj = wifiObj.SPAirPortDataType[0].spairport_airport_interfaces[0].spairport_airport_other_local_wireless_networks;
|
|
405
|
-
wifiObj.forEach(
|
|
406
|
-
|
|
407
|
-
let security = [];
|
|
376
|
+
wifiObj.forEach((wifiItem) => {
|
|
377
|
+
const security = [];
|
|
408
378
|
const sm = wifiItem.spairport_security_mode || '';
|
|
409
379
|
if (sm === 'spairport_security_mode_wep') {
|
|
410
380
|
security.push('WEP');
|
|
@@ -437,7 +407,7 @@ function parseWifiDarwin(wifiStr) {
|
|
|
437
407
|
} catch (e) {
|
|
438
408
|
return result;
|
|
439
409
|
}
|
|
440
|
-
}
|
|
410
|
+
}
|
|
441
411
|
function wifiNetworks(callback) {
|
|
442
412
|
return new Promise((resolve) => {
|
|
443
413
|
process.nextTick(() => {
|
|
@@ -448,7 +418,7 @@ function wifiNetworks(callback) {
|
|
|
448
418
|
try {
|
|
449
419
|
const iwconfigParts = execSync('export LC_ALL=C; iwconfig 2>/dev/null; unset LC_ALL', util.execOptsLinux).toString().split('\n\n');
|
|
450
420
|
let iface = '';
|
|
451
|
-
iwconfigParts.forEach(element => {
|
|
421
|
+
iwconfigParts.forEach((element) => {
|
|
452
422
|
if (element.indexOf('no wireless') === -1 && element.trim() !== '') {
|
|
453
423
|
iface = element.split(' ')[0];
|
|
454
424
|
}
|
|
@@ -467,9 +437,11 @@ function wifiNetworks(callback) {
|
|
|
467
437
|
const res = getWifiNetworkListIw(ifaceSanitized);
|
|
468
438
|
if (res === -1) {
|
|
469
439
|
// try again after 4 secs
|
|
470
|
-
setTimeout(
|
|
440
|
+
setTimeout((iface) => {
|
|
471
441
|
const res = getWifiNetworkListIw(iface);
|
|
472
|
-
if (res
|
|
442
|
+
if (res !== -1) {
|
|
443
|
+
result = res;
|
|
444
|
+
}
|
|
473
445
|
if (callback) {
|
|
474
446
|
callback(result);
|
|
475
447
|
}
|
|
@@ -501,8 +473,8 @@ function wifiNetworks(callback) {
|
|
|
501
473
|
resolve(result);
|
|
502
474
|
}
|
|
503
475
|
} else if (_darwin) {
|
|
504
|
-
|
|
505
|
-
exec(cmd, { maxBuffer: 1024 * 40000 },
|
|
476
|
+
const cmd = 'system_profiler SPAirPortDataType -json 2>/dev/null';
|
|
477
|
+
exec(cmd, { maxBuffer: 1024 * 40000 }, (error, stdout) => {
|
|
506
478
|
result = parseWifiDarwin(stdout.toString());
|
|
507
479
|
if (callback) {
|
|
508
480
|
callback(result);
|
|
@@ -510,12 +482,12 @@ function wifiNetworks(callback) {
|
|
|
510
482
|
resolve(result);
|
|
511
483
|
});
|
|
512
484
|
} else if (_windows) {
|
|
513
|
-
|
|
485
|
+
const cmd = 'netsh wlan show networks mode=Bssid';
|
|
514
486
|
util.powerShell(cmd).then((stdout) => {
|
|
515
487
|
const ssidParts = stdout.toString('utf8').split(os.EOL + os.EOL + 'SSID ');
|
|
516
488
|
ssidParts.shift();
|
|
517
489
|
|
|
518
|
-
ssidParts.forEach(ssidPart => {
|
|
490
|
+
ssidParts.forEach((ssidPart) => {
|
|
519
491
|
const ssidLines = ssidPart.split(os.EOL);
|
|
520
492
|
if (ssidLines && ssidLines.length >= 8 && ssidLines[0].indexOf(':') >= 0) {
|
|
521
493
|
const bssidsParts = ssidPart.split(' BSSID');
|
|
@@ -565,29 +537,46 @@ exports.wifiNetworks = wifiNetworks;
|
|
|
565
537
|
function getVendor(model) {
|
|
566
538
|
model = model.toLowerCase();
|
|
567
539
|
let result = '';
|
|
568
|
-
if (model.indexOf('intel') >= 0) {
|
|
569
|
-
|
|
570
|
-
else if (model.indexOf('
|
|
571
|
-
|
|
572
|
-
else if (model.indexOf('
|
|
573
|
-
|
|
574
|
-
else if (model.indexOf('
|
|
575
|
-
|
|
576
|
-
else if (model.indexOf('
|
|
577
|
-
|
|
578
|
-
else if (model.indexOf('
|
|
579
|
-
|
|
580
|
-
else if (model.indexOf('
|
|
540
|
+
if (model.indexOf('intel') >= 0) {
|
|
541
|
+
result = 'Intel';
|
|
542
|
+
} else if (model.indexOf('realtek') >= 0) {
|
|
543
|
+
result = 'Realtek';
|
|
544
|
+
} else if (model.indexOf('qualcom') >= 0) {
|
|
545
|
+
result = 'Qualcom';
|
|
546
|
+
} else if (model.indexOf('broadcom') >= 0) {
|
|
547
|
+
result = 'Broadcom';
|
|
548
|
+
} else if (model.indexOf('cavium') >= 0) {
|
|
549
|
+
result = 'Cavium';
|
|
550
|
+
} else if (model.indexOf('cisco') >= 0) {
|
|
551
|
+
result = 'Cisco';
|
|
552
|
+
} else if (model.indexOf('marvel') >= 0) {
|
|
553
|
+
result = 'Marvel';
|
|
554
|
+
} else if (model.indexOf('zyxel') >= 0) {
|
|
555
|
+
result = 'Zyxel';
|
|
556
|
+
} else if (model.indexOf('melanox') >= 0) {
|
|
557
|
+
result = 'Melanox';
|
|
558
|
+
} else if (model.indexOf('d-link') >= 0) {
|
|
559
|
+
result = 'D-Link';
|
|
560
|
+
} else if (model.indexOf('tp-link') >= 0) {
|
|
561
|
+
result = 'TP-Link';
|
|
562
|
+
} else if (model.indexOf('asus') >= 0) {
|
|
563
|
+
result = 'Asus';
|
|
564
|
+
} else if (model.indexOf('linksys') >= 0) {
|
|
565
|
+
result = 'Linksys';
|
|
566
|
+
}
|
|
581
567
|
return result;
|
|
582
568
|
}
|
|
583
569
|
|
|
584
570
|
function formatBssid(s) {
|
|
585
|
-
s =
|
|
571
|
+
s =
|
|
572
|
+
s
|
|
573
|
+
.replace(/</g, '')
|
|
574
|
+
.replace(/>/g, '')
|
|
575
|
+
.match(/.{1,2}/g) || [];
|
|
586
576
|
return s.join(':');
|
|
587
577
|
}
|
|
588
578
|
|
|
589
579
|
function wifiConnections(callback) {
|
|
590
|
-
|
|
591
580
|
return new Promise((resolve) => {
|
|
592
581
|
process.nextTick(() => {
|
|
593
582
|
const result = [];
|
|
@@ -595,7 +584,7 @@ function wifiConnections(callback) {
|
|
|
595
584
|
if (_linux) {
|
|
596
585
|
const ifaces = ifaceListLinux();
|
|
597
586
|
const networkList = getWifiNetworkListNmi();
|
|
598
|
-
ifaces.forEach(ifaceDetail => {
|
|
587
|
+
ifaces.forEach((ifaceDetail) => {
|
|
599
588
|
let ifaceSanitized = '';
|
|
600
589
|
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ifaceDetail.iface, true);
|
|
601
590
|
const ll = util.mathMin(s.length, 2000);
|
|
@@ -609,7 +598,7 @@ function wifiConnections(callback) {
|
|
|
609
598
|
const nmiDetails = nmiDeviceLinux(ifaceSanitized);
|
|
610
599
|
const wpaDetails = wpaConnectionLinux(ifaceSanitized);
|
|
611
600
|
const ssid = nmiDetails.ssid || wpaDetails.ssid;
|
|
612
|
-
const network = networkList.filter(nw => nw.ssid === ssid);
|
|
601
|
+
const network = networkList.filter((nw) => nw.ssid === ssid);
|
|
613
602
|
let ssidSanitized = '';
|
|
614
603
|
const t = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ssid, true);
|
|
615
604
|
const l = util.mathMin(t.length, 32);
|
|
@@ -620,8 +609,8 @@ function wifiConnections(callback) {
|
|
|
620
609
|
}
|
|
621
610
|
|
|
622
611
|
const nmiConnection = nmiConnectionLinux(ssidSanitized);
|
|
623
|
-
const channel = network && network.length && network[0].channel ? network[0].channel :
|
|
624
|
-
const bssid = network && network.length && network[0].bssid ? network[0].bssid :
|
|
612
|
+
const channel = network && network.length && network[0].channel ? network[0].channel : wpaDetails.channel ? wpaDetails.channel : null;
|
|
613
|
+
const bssid = network && network.length && network[0].bssid ? network[0].bssid : wpaDetails.bssid ? wpaDetails.bssid : null;
|
|
625
614
|
const signalLevel = network && network.length && network[0].signalLevel ? network[0].signalLevel : null;
|
|
626
615
|
if (ssid && bssid) {
|
|
627
616
|
result.push({
|
|
@@ -629,11 +618,11 @@ function wifiConnections(callback) {
|
|
|
629
618
|
iface: ifaceDetail.iface,
|
|
630
619
|
model: nmiDetails.product,
|
|
631
620
|
ssid,
|
|
632
|
-
bssid: network && network.length && network[0].bssid ? network[0].bssid :
|
|
621
|
+
bssid: network && network.length && network[0].bssid ? network[0].bssid : wpaDetails.bssid ? wpaDetails.bssid : null,
|
|
633
622
|
channel,
|
|
634
623
|
frequency: channel ? wifiFrequencyFromChannel(channel) : null,
|
|
635
624
|
type: nmiConnection.type ? nmiConnection.type : '802.11',
|
|
636
|
-
security: nmiConnection.security ? nmiConnection.security :
|
|
625
|
+
security: nmiConnection.security ? nmiConnection.security : wpaDetails.security ? wpaDetails.security : null,
|
|
637
626
|
signalLevel,
|
|
638
627
|
quality: wifiQualityFromDB(signalLevel),
|
|
639
628
|
txRate: null
|
|
@@ -645,13 +634,14 @@ function wifiConnections(callback) {
|
|
|
645
634
|
}
|
|
646
635
|
resolve(result);
|
|
647
636
|
} else if (_darwin) {
|
|
648
|
-
|
|
649
|
-
exec(cmd,
|
|
637
|
+
const cmd = 'system_profiler SPNetworkDataType SPAirPortDataType -xml 2>/dev/null; echo "######" ; ioreg -n AppleBCMWLANSkywalkInterface -r 2>/dev/null';
|
|
638
|
+
exec(cmd, (error, stdout) => {
|
|
650
639
|
try {
|
|
651
640
|
const parts = stdout.toString().split('######');
|
|
652
641
|
const profilerObj = util.plistParser(parts[0]);
|
|
653
642
|
const networkObj = profilerObj[0]._SPCommandLineArguments.indexOf('SPNetworkDataType') >= 0 ? profilerObj[0]._items : profilerObj[1]._items;
|
|
654
|
-
const airportObj =
|
|
643
|
+
const airportObj =
|
|
644
|
+
profilerObj[0]._SPCommandLineArguments.indexOf('SPAirPortDataType') >= 0 ? profilerObj[0]._items[0].spairport_airport_interfaces : profilerObj[1]._items[0].spairport_airport_interfaces;
|
|
655
645
|
|
|
656
646
|
// parts[1] : ioreg
|
|
657
647
|
let lines3 = [];
|
|
@@ -659,13 +649,15 @@ function wifiConnections(callback) {
|
|
|
659
649
|
lines3 = parts[1].split(' | {')[1].split(' | }')[0].replace(/ \| /g, '').replace(/"/g, '').split('\n');
|
|
660
650
|
}
|
|
661
651
|
|
|
662
|
-
const networkWifiObj = networkObj.find((item) => {
|
|
652
|
+
const networkWifiObj = networkObj.find((item) => {
|
|
653
|
+
return item._name === 'Wi-Fi';
|
|
654
|
+
});
|
|
663
655
|
const airportWifiObj = airportObj[0].spairport_current_network_information;
|
|
664
656
|
|
|
665
|
-
const channel = parseInt(('' + airportWifiObj.spairport_network_channel).split(' ')[0]) || 0;
|
|
657
|
+
const channel = parseInt(('' + airportWifiObj.spairport_network_channel).split(' ')[0], 10) || 0;
|
|
666
658
|
const signalLevel = airportWifiObj.spairport_signal_noise || null;
|
|
667
659
|
|
|
668
|
-
|
|
660
|
+
const security = [];
|
|
669
661
|
const sm = airportWifiObj.spairport_security_mode || '';
|
|
670
662
|
if (sm === 'spairport_security_mode_wep') {
|
|
671
663
|
security.push('WEP');
|
|
@@ -683,7 +675,7 @@ function wifiConnections(callback) {
|
|
|
683
675
|
id: networkWifiObj._name || 'Wi-Fi',
|
|
684
676
|
iface: networkWifiObj.interface || '',
|
|
685
677
|
model: networkWifiObj.hardware || '',
|
|
686
|
-
ssid: airportWifiObj._name || '',
|
|
678
|
+
ssid: (airportWifiObj._name || '').replace('<', '<').replace('>', '>'),
|
|
687
679
|
bssid: airportWifiObj.spairport_network_bssid || '',
|
|
688
680
|
channel,
|
|
689
681
|
frequency: channel ? wifiFrequencyFromChannel(channel) : null,
|
|
@@ -691,10 +683,9 @@ function wifiConnections(callback) {
|
|
|
691
683
|
security,
|
|
692
684
|
signalLevel: signalLevel ? parseInt(signalLevel, 10) : null,
|
|
693
685
|
quality: wifiQualityFromDB(signalLevel),
|
|
694
|
-
txRate: airportWifiObj.spairport_network_rate || null
|
|
686
|
+
txRate: airportWifiObj.spairport_network_rate || null
|
|
695
687
|
});
|
|
696
|
-
|
|
697
|
-
} catch (e) {
|
|
688
|
+
} catch {
|
|
698
689
|
util.noop();
|
|
699
690
|
}
|
|
700
691
|
if (callback) {
|
|
@@ -703,15 +694,15 @@ function wifiConnections(callback) {
|
|
|
703
694
|
resolve(result);
|
|
704
695
|
});
|
|
705
696
|
} else if (_windows) {
|
|
706
|
-
|
|
707
|
-
util.powerShell(cmd).then(
|
|
697
|
+
const cmd = 'netsh wlan show interfaces';
|
|
698
|
+
util.powerShell(cmd).then((stdout) => {
|
|
708
699
|
const allLines = stdout.toString().split('\r\n');
|
|
709
700
|
for (let i = 0; i < allLines.length; i++) {
|
|
710
701
|
allLines[i] = allLines[i].trim();
|
|
711
702
|
}
|
|
712
703
|
const parts = allLines.join('\r\n').split(':\r\n\r\n');
|
|
713
704
|
parts.shift();
|
|
714
|
-
parts.forEach(part => {
|
|
705
|
+
parts.forEach((part) => {
|
|
715
706
|
const lines = part.split('\r\n');
|
|
716
707
|
if (lines.length >= 5) {
|
|
717
708
|
const iface = lines[0].indexOf(':') >= 0 ? lines[0].split(':')[1].trim() : '';
|
|
@@ -724,7 +715,8 @@ function wifiConnections(callback) {
|
|
|
724
715
|
const type = util.getValue(lines, 'Radio type', ':', true) || util.getValue(lines, 'Type de radio', ':', true) || util.getValue(lines, 'Funktyp', ':', true) || null;
|
|
725
716
|
const security = util.getValue(lines, 'authentication', ':', true) || util.getValue(lines, 'Authentification', ':', true) || util.getValue(lines, 'Authentifizierung', ':', true) || null;
|
|
726
717
|
const channel = util.getValue(lines, 'Channel', ':', true) || util.getValue(lines, 'Canal', ':', true) || util.getValue(lines, 'Kanal', ':', true) || null;
|
|
727
|
-
const txRate =
|
|
718
|
+
const txRate =
|
|
719
|
+
util.getValue(lines, 'Transmit rate (mbps)', ':', true) || util.getValue(lines, 'Transmission (mbit/s)', ':', true) || util.getValue(lines, 'Empfangsrate (MBit/s)', ':', true) || null;
|
|
728
720
|
if (model && id && ssid && bssid) {
|
|
729
721
|
result.push({
|
|
730
722
|
id,
|
|
@@ -761,21 +753,20 @@ function wifiConnections(callback) {
|
|
|
761
753
|
exports.wifiConnections = wifiConnections;
|
|
762
754
|
|
|
763
755
|
function wifiInterfaces(callback) {
|
|
764
|
-
|
|
765
756
|
return new Promise((resolve) => {
|
|
766
757
|
process.nextTick(() => {
|
|
767
758
|
const result = [];
|
|
768
759
|
|
|
769
760
|
if (_linux) {
|
|
770
761
|
const ifaces = ifaceListLinux();
|
|
771
|
-
ifaces.forEach(ifaceDetail => {
|
|
762
|
+
ifaces.forEach((ifaceDetail) => {
|
|
772
763
|
const nmiDetails = nmiDeviceLinux(ifaceDetail.iface);
|
|
773
764
|
result.push({
|
|
774
765
|
id: ifaceDetail.id,
|
|
775
766
|
iface: ifaceDetail.iface,
|
|
776
767
|
model: nmiDetails.product ? nmiDetails.product : null,
|
|
777
768
|
vendor: nmiDetails.vendor ? nmiDetails.vendor : null,
|
|
778
|
-
mac: ifaceDetail.mac
|
|
769
|
+
mac: ifaceDetail.mac
|
|
779
770
|
});
|
|
780
771
|
});
|
|
781
772
|
if (callback) {
|
|
@@ -783,8 +774,8 @@ function wifiInterfaces(callback) {
|
|
|
783
774
|
}
|
|
784
775
|
resolve(result);
|
|
785
776
|
} else if (_darwin) {
|
|
786
|
-
|
|
787
|
-
exec(cmd,
|
|
777
|
+
const cmd = 'system_profiler SPNetworkDataType';
|
|
778
|
+
exec(cmd, (error, stdout) => {
|
|
788
779
|
const parts1 = stdout.toString().split('\n\n Wi-Fi:\n\n');
|
|
789
780
|
if (parts1.length > 1) {
|
|
790
781
|
const lines = parts1[1].split('\n\n')[0].split('\n');
|
|
@@ -805,15 +796,15 @@ function wifiInterfaces(callback) {
|
|
|
805
796
|
resolve(result);
|
|
806
797
|
});
|
|
807
798
|
} else if (_windows) {
|
|
808
|
-
|
|
809
|
-
util.powerShell(cmd).then(
|
|
799
|
+
const cmd = 'netsh wlan show interfaces';
|
|
800
|
+
util.powerShell(cmd).then((stdout) => {
|
|
810
801
|
const allLines = stdout.toString().split('\r\n');
|
|
811
802
|
for (let i = 0; i < allLines.length; i++) {
|
|
812
803
|
allLines[i] = allLines[i].trim();
|
|
813
804
|
}
|
|
814
805
|
const parts = allLines.join('\r\n').split(':\r\n\r\n');
|
|
815
806
|
parts.shift();
|
|
816
|
-
parts.forEach(part => {
|
|
807
|
+
parts.forEach((part) => {
|
|
817
808
|
const lines = part.split('\r\n');
|
|
818
809
|
if (lines.length >= 5) {
|
|
819
810
|
const iface = lines[0].indexOf(':') >= 0 ? lines[0].split(':')[1].trim() : '';
|
|
@@ -829,7 +820,7 @@ function wifiInterfaces(callback) {
|
|
|
829
820
|
iface,
|
|
830
821
|
model,
|
|
831
822
|
vendor,
|
|
832
|
-
mac
|
|
823
|
+
mac
|
|
833
824
|
});
|
|
834
825
|
}
|
|
835
826
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.28.0",
|
|
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)",
|