systeminformation 5.9.14 → 5.9.18
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/cpu.js +5 -5
- package/lib/index.js +513 -511
- package/lib/util.js +235 -117
- package/lib/wifi.js +72 -41
- package/package.json +1 -1
package/lib/util.js
CHANGED
|
@@ -37,6 +37,17 @@ let _smartMonToolsInstalled = null;
|
|
|
37
37
|
|
|
38
38
|
const WINDIR = process.env.WINDIR || 'C:\\Windows';
|
|
39
39
|
|
|
40
|
+
// powerShell
|
|
41
|
+
let _psChild;
|
|
42
|
+
let _psResult = '';
|
|
43
|
+
let _psCmds = [];
|
|
44
|
+
let _psPersistent = false;
|
|
45
|
+
const _psToUTF8 = '$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8 ; ';
|
|
46
|
+
const _psCmdStart = '--###START###--';
|
|
47
|
+
const _psError = '--ERROR--';
|
|
48
|
+
const _psCmdSeperator = '--###ENDCMD###--';
|
|
49
|
+
const _psIdSeperator = '--##ID##--';
|
|
50
|
+
|
|
40
51
|
const execOptsWin = {
|
|
41
52
|
windowsHide: true,
|
|
42
53
|
maxBuffer: 1024 * 20000,
|
|
@@ -352,59 +363,157 @@ function getVboxmanage() {
|
|
|
352
363
|
return _windows ? `"${process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH}\\VBoxManage.exe"` : 'vboxmanage';
|
|
353
364
|
}
|
|
354
365
|
|
|
355
|
-
function
|
|
366
|
+
function powerShellProceedResults(data) {
|
|
367
|
+
let id = '';
|
|
368
|
+
let parts;
|
|
369
|
+
let res = '';
|
|
370
|
+
// startID
|
|
371
|
+
if (data.indexOf(_psCmdStart) >= 0) {
|
|
372
|
+
parts = data.split(_psCmdStart);
|
|
373
|
+
const parts2 = parts[1].split(_psIdSeperator);
|
|
374
|
+
id = parts2[0];
|
|
375
|
+
if (parts2.length > 1) {
|
|
376
|
+
data = parts2.slice(1).join(_psIdSeperator);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// result;
|
|
380
|
+
if (data.indexOf(_psCmdSeperator) >= 0) {
|
|
381
|
+
parts = data.split(_psCmdSeperator);
|
|
382
|
+
res = parts[0];
|
|
383
|
+
}
|
|
384
|
+
let remove = -1;
|
|
385
|
+
for (let i = 0; i < _psCmds.length; i++) {
|
|
386
|
+
if (_psCmds[i].id === id) {
|
|
387
|
+
remove = i;
|
|
388
|
+
// console.log(`----- TIME : ${(new Date() - _psCmds[i].start) * 0.001} s`);
|
|
356
389
|
|
|
357
|
-
|
|
358
|
-
|
|
390
|
+
_psCmds[i].callback(res);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (remove >= 0) {
|
|
394
|
+
_psCmds.splice(remove, 1);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
359
397
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
398
|
+
function powerShellStart() {
|
|
399
|
+
_psChild = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
|
|
400
|
+
stdio: 'pipe',
|
|
401
|
+
windowsHide: true,
|
|
402
|
+
maxBuffer: 1024 * 20000,
|
|
403
|
+
encoding: 'UTF-8',
|
|
404
|
+
env: util._extend({}, process.env, { LANG: 'en_US.UTF-8' })
|
|
405
|
+
});
|
|
406
|
+
if (_psChild && _psChild.pid) {
|
|
407
|
+
_psPersistent = true;
|
|
408
|
+
_psChild.stdout.on('data', function (data) {
|
|
409
|
+
_psResult = _psResult + data.toString('utf8');
|
|
410
|
+
if (data.indexOf(_psCmdSeperator) >= 0) {
|
|
411
|
+
powerShellProceedResults(_psResult);
|
|
412
|
+
_psResult = '';
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
_psChild.stderr.on('data', function () {
|
|
416
|
+
powerShellProceedResults(_psResult + _psError);
|
|
417
|
+
});
|
|
418
|
+
_psChild.on('error', function () {
|
|
419
|
+
powerShellProceedResults(_psResult + _psError);
|
|
420
|
+
});
|
|
421
|
+
_psChild.on('close', function () {
|
|
422
|
+
_psChild.kill();
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}
|
|
370
426
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
427
|
+
function powerShellRelease() {
|
|
428
|
+
try {
|
|
429
|
+
_psChild.stdin.write('exit' + os.EOL);
|
|
430
|
+
_psChild.stdin.end();
|
|
431
|
+
_psPersistent = false;
|
|
432
|
+
} catch (e) {
|
|
433
|
+
_psChild.kill();
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function powerShell(cmd) {
|
|
438
|
+
|
|
439
|
+
if (_psPersistent) {
|
|
440
|
+
const id = Math.random().toString(36).substr(2, 10);
|
|
441
|
+
return new Promise((resolve) => {
|
|
442
|
+
process.nextTick(() => {
|
|
443
|
+
function callback(data) {
|
|
444
|
+
resolve(data);
|
|
375
445
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
446
|
+
_psCmds.push({
|
|
447
|
+
id,
|
|
448
|
+
cmd,
|
|
449
|
+
callback,
|
|
450
|
+
start: new Date()
|
|
451
|
+
});
|
|
452
|
+
try {
|
|
453
|
+
if (_psChild && _psChild.pid) {
|
|
454
|
+
_psChild.stdin.write(_psToUTF8 + 'echo ' + _psCmdStart + id + _psIdSeperator + '; ' + os.EOL + cmd + os.EOL + 'echo ' + _psCmdSeperator + os.EOL);
|
|
455
|
+
}
|
|
456
|
+
} catch (e) {
|
|
457
|
+
resolve('');
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
} else {
|
|
463
|
+
let result = '';
|
|
464
|
+
|
|
465
|
+
return new Promise((resolve) => {
|
|
466
|
+
process.nextTick(() => {
|
|
467
|
+
try {
|
|
468
|
+
// const start = new Date();
|
|
469
|
+
const child = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
|
|
470
|
+
stdio: 'pipe',
|
|
471
|
+
windowsHide: true,
|
|
472
|
+
maxBuffer: 1024 * 20000,
|
|
473
|
+
encoding: 'UTF-8',
|
|
474
|
+
env: util._extend({}, process.env, { LANG: 'en_US.UTF-8' })
|
|
391
475
|
});
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
child.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
476
|
+
|
|
477
|
+
if (child && !child.pid) {
|
|
478
|
+
child.on('error', function () {
|
|
479
|
+
resolve(result);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
if (child && child.pid) {
|
|
483
|
+
child.stdout.on('data', function (data) {
|
|
484
|
+
result = result + data.toString('utf8');
|
|
485
|
+
});
|
|
486
|
+
child.stderr.on('data', function () {
|
|
487
|
+
child.kill();
|
|
488
|
+
resolve(result);
|
|
489
|
+
});
|
|
490
|
+
child.on('close', function () {
|
|
491
|
+
child.kill();
|
|
492
|
+
// console.log(`----- TIME : ${(new Date() - start) * 0.001} s`);
|
|
493
|
+
|
|
494
|
+
resolve(result);
|
|
495
|
+
});
|
|
496
|
+
child.on('error', function () {
|
|
497
|
+
child.kill();
|
|
498
|
+
resolve(result);
|
|
499
|
+
});
|
|
500
|
+
try {
|
|
501
|
+
child.stdin.write(_psToUTF8 + cmd + os.EOL);
|
|
502
|
+
child.stdin.write('exit' + os.EOL);
|
|
503
|
+
child.stdin.end();
|
|
504
|
+
} catch (e) {
|
|
505
|
+
child.kill();
|
|
506
|
+
resolve(result);
|
|
507
|
+
}
|
|
508
|
+
} else {
|
|
398
509
|
resolve(result);
|
|
399
510
|
}
|
|
400
|
-
}
|
|
511
|
+
} catch (e) {
|
|
401
512
|
resolve(result);
|
|
402
513
|
}
|
|
403
|
-
}
|
|
404
|
-
resolve(result);
|
|
405
|
-
}
|
|
514
|
+
});
|
|
406
515
|
});
|
|
407
|
-
}
|
|
516
|
+
}
|
|
408
517
|
}
|
|
409
518
|
|
|
410
519
|
function execSafe(cmd, args, options) {
|
|
@@ -1002,91 +1111,98 @@ function linuxVersion() {
|
|
|
1002
1111
|
}
|
|
1003
1112
|
|
|
1004
1113
|
function plistParser(xmlStr) {
|
|
1005
|
-
const tags = ['array', 'dict', 'key', 'string', 'integer', 'date', 'real', 'data'];
|
|
1006
|
-
|
|
1007
|
-
function getNextTagPos() {
|
|
1008
|
-
let result = {
|
|
1009
|
-
pos: 999999,
|
|
1010
|
-
tag: ''
|
|
1011
|
-
};
|
|
1012
|
-
tags.forEach((tag) => {
|
|
1013
|
-
const ii = xmlStr.indexOf(`<${tag}>`);
|
|
1014
|
-
if (ii !== -1 && ii < result.pos) {
|
|
1015
|
-
result = {
|
|
1016
|
-
pos: ii,
|
|
1017
|
-
tag
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
});
|
|
1021
|
-
return result;
|
|
1022
|
-
}
|
|
1114
|
+
const tags = ['array', 'dict', 'key', 'string', 'integer', 'date', 'real', 'data', 'boolean', 'arrayEmpty'];
|
|
1115
|
+
const startStr = '<plist version';
|
|
1023
1116
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1117
|
+
let pos = xmlStr.indexOf(startStr);
|
|
1118
|
+
let len = xmlStr.length;
|
|
1119
|
+
while (xmlStr[pos] !== '>' && pos < len) {
|
|
1120
|
+
pos++;
|
|
1026
1121
|
}
|
|
1027
1122
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1123
|
+
let depth = 0;
|
|
1124
|
+
let inTagStart = false;
|
|
1125
|
+
let inTagContent = false;
|
|
1126
|
+
let inTagEnd = false;
|
|
1127
|
+
let metaData = [{ tagStart: '', tagEnd: '', tagContent: '', key: '', data: null }];
|
|
1128
|
+
let c = '';
|
|
1129
|
+
let cn = xmlStr[pos];
|
|
1130
|
+
|
|
1131
|
+
while (pos < len) {
|
|
1132
|
+
c = cn;
|
|
1133
|
+
if (pos + 1 < len) { cn = xmlStr[pos + 1]; }
|
|
1134
|
+
if (c === '<') {
|
|
1135
|
+
inTagContent = false;
|
|
1136
|
+
if (cn === '/') { inTagEnd = true; }
|
|
1137
|
+
else if (metaData[depth].tagStart) {
|
|
1138
|
+
metaData[depth].tagContent = '';
|
|
1139
|
+
if (!metaData[depth].data) { metaData[depth].data = metaData[depth].tagStart === 'array' ? [] : {}; }
|
|
1140
|
+
depth++;
|
|
1141
|
+
metaData.push({ tagStart: '', tagEnd: '', tagContent: '', key: null, data: null });
|
|
1142
|
+
inTagStart = true;
|
|
1143
|
+
inTagContent = false;
|
|
1042
1144
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1145
|
+
else if (!inTagStart) { inTagStart = true; }
|
|
1146
|
+
} else if (c === '>') {
|
|
1147
|
+
if (metaData[depth].tagStart === 'true/') { inTagStart = false; inTagEnd = true; metaData[depth].tagStart = ''; metaData[depth].tagEnd = '/boolean'; metaData[depth].data = true; }
|
|
1148
|
+
if (metaData[depth].tagStart === 'false/') { inTagStart = false; inTagEnd = true; metaData[depth].tagStart = ''; metaData[depth].tagEnd = '/boolean'; metaData[depth].data = false; }
|
|
1149
|
+
if (metaData[depth].tagStart === 'array/') { inTagStart = false; inTagEnd = true; metaData[depth].tagStart = ''; metaData[depth].tagEnd = '/arrayEmpty'; metaData[depth].data = []; }
|
|
1150
|
+
if (inTagContent) { inTagContent = false; }
|
|
1151
|
+
if (inTagStart) {
|
|
1152
|
+
inTagStart = false;
|
|
1153
|
+
inTagContent = true;
|
|
1154
|
+
if (metaData[depth].tagStart === 'array') {
|
|
1155
|
+
metaData[depth].data = [];
|
|
1050
1156
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
if (!isArray) {
|
|
1054
|
-
obj[key] = res;
|
|
1055
|
-
} else {
|
|
1056
|
-
arr.push(res);
|
|
1157
|
+
if (metaData[depth].tagStart === 'dict') {
|
|
1158
|
+
metaData[depth].data = {};
|
|
1057
1159
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1160
|
+
}
|
|
1161
|
+
if (inTagEnd) {
|
|
1162
|
+
inTagEnd = false;
|
|
1163
|
+
if (metaData[depth].tagEnd && tags.indexOf(metaData[depth].tagEnd.substr(1)) >= 0) {
|
|
1164
|
+
if (metaData[depth].tagEnd === '/dict' || metaData[depth].tagEnd === '/array') {
|
|
1165
|
+
if (depth > 1 && metaData[depth - 2].tagStart === 'array') {
|
|
1166
|
+
metaData[depth - 2].data.push(metaData[depth - 1].data);
|
|
1167
|
+
}
|
|
1168
|
+
if (depth > 1 && metaData[depth - 2].tagStart === 'dict') {
|
|
1169
|
+
metaData[depth - 2].data[metaData[depth - 1].key] = metaData[depth - 1].data;
|
|
1170
|
+
}
|
|
1171
|
+
depth--;
|
|
1172
|
+
metaData.pop();
|
|
1173
|
+
metaData[depth].tagContent = '';
|
|
1174
|
+
metaData[depth].tagStart = '';
|
|
1175
|
+
metaData[depth].tagEnd = '';
|
|
1176
|
+
}
|
|
1177
|
+
else {
|
|
1178
|
+
if (metaData[depth].tagEnd === '/key' && metaData[depth].tagContent) {
|
|
1179
|
+
metaData[depth].key = metaData[depth].tagContent;
|
|
1180
|
+
} else {
|
|
1181
|
+
if (metaData[depth].tagEnd === '/real' && metaData[depth].tagContent) { metaData[depth].data = parseFloat(metaData[depth].tagContent) || 0; }
|
|
1182
|
+
if (metaData[depth].tagEnd === '/integer' && metaData[depth].tagContent) { metaData[depth].data = parseInt(metaData[depth].tagContent) || 0; }
|
|
1183
|
+
if (metaData[depth].tagEnd === '/string' && metaData[depth].tagContent) { metaData[depth].data = metaData[depth].tagContent || ''; }
|
|
1184
|
+
if (metaData[depth].tagEnd === '/boolean') { metaData[depth].data = metaData[depth].tagContent || false; }
|
|
1185
|
+
if (metaData[depth].tagEnd === '/arrayEmpty') { metaData[depth].data = metaData[depth].tagContent || []; }
|
|
1186
|
+
if (depth > 0 && metaData[depth - 1].tagStart === 'array') { metaData[depth - 1].data.push(metaData[depth].data); }
|
|
1187
|
+
if (depth > 0 && metaData[depth - 1].tagStart === 'dict') { metaData[depth - 1].data[metaData[depth].key] = metaData[depth].data; }
|
|
1188
|
+
}
|
|
1189
|
+
metaData[depth].tagContent = '';
|
|
1190
|
+
metaData[depth].tagStart = '';
|
|
1191
|
+
metaData[depth].tagEnd = '';
|
|
1077
1192
|
}
|
|
1078
1193
|
}
|
|
1194
|
+
metaData[depth].tagEnd = '';
|
|
1195
|
+
inTagStart = false;
|
|
1196
|
+
inTagContent = false;
|
|
1079
1197
|
}
|
|
1080
|
-
|
|
1198
|
+
} else {
|
|
1199
|
+
if (inTagStart) { metaData[depth].tagStart += c; }
|
|
1200
|
+
if (inTagEnd) { metaData[depth].tagEnd += c; }
|
|
1201
|
+
if (inTagContent) { metaData[depth].tagContent += c; }
|
|
1081
1202
|
}
|
|
1082
|
-
|
|
1083
|
-
}
|
|
1084
|
-
try {
|
|
1085
|
-
const result = parseXmlTree(false, '');
|
|
1086
|
-
return result;
|
|
1087
|
-
} catch (e) {
|
|
1088
|
-
return {};
|
|
1203
|
+
pos++;
|
|
1089
1204
|
}
|
|
1205
|
+
return metaData[0].data;
|
|
1090
1206
|
}
|
|
1091
1207
|
|
|
1092
1208
|
function semverCompare(v1, v2) {
|
|
@@ -1130,6 +1246,8 @@ exports.wmic = wmic;
|
|
|
1130
1246
|
exports.darwinXcodeExists = darwinXcodeExists;
|
|
1131
1247
|
exports.getVboxmanage = getVboxmanage;
|
|
1132
1248
|
exports.powerShell = powerShell;
|
|
1249
|
+
exports.powerShellStart = powerShellStart;
|
|
1250
|
+
exports.powerShellRelease = powerShellRelease;
|
|
1133
1251
|
exports.execSafe = execSafe;
|
|
1134
1252
|
exports.nanoSeconds = nanoSeconds;
|
|
1135
1253
|
exports.countUniqueLines = countUniqueLines;
|
package/lib/wifi.js
CHANGED
|
@@ -315,8 +315,74 @@ function getWifiNetworkListIw(iface) {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
|
|
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: []
|
|
319
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
|
+
function parseWifiDarwin(wifiObj) {
|
|
343
|
+
const result = [];
|
|
344
|
+
if (wifiObj) {
|
|
345
|
+
wifiObj.forEach(function (wifiItem) {
|
|
346
|
+
const signalLevel = wifiItem.RSSI;
|
|
347
|
+
let security = [];
|
|
348
|
+
let wpaFlags = [];
|
|
349
|
+
if (wifiItem.WPA_IE) {
|
|
350
|
+
security.push('WPA');
|
|
351
|
+
if (wifiItem.WPA_IE.IE_KEY_WPA_UCIPHERS) {
|
|
352
|
+
wifiItem.WPA_IE.IE_KEY_WPA_UCIPHERS.forEach(function (ciphers) {
|
|
353
|
+
if (ciphers === 0 && wpaFlags.indexOf('unknown/TKIP') === -1) { wpaFlags.push('unknown/TKIP'); }
|
|
354
|
+
if (ciphers === 2 && wpaFlags.indexOf('PSK/TKIP') === -1) { wpaFlags.push('PSK/TKIP'); }
|
|
355
|
+
if (ciphers === 4 && wpaFlags.indexOf('PSK/AES') === -1) { wpaFlags.push('PSK/AES'); }
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (wifiItem.RSN_IE) {
|
|
360
|
+
security.push('WPA2');
|
|
361
|
+
if (wifiItem.RSN_IE.IE_KEY_RSN_UCIPHERS) {
|
|
362
|
+
wifiItem.RSN_IE.IE_KEY_RSN_UCIPHERS.forEach(function (ciphers) {
|
|
363
|
+
if (ciphers === 0 && wpaFlags.indexOf('unknown/TKIP') === -1) { wpaFlags.push('unknown/TKIP'); }
|
|
364
|
+
if (ciphers === 2 && wpaFlags.indexOf('TKIP/TKIP') === -1) { wpaFlags.push('TKIP/TKIP'); }
|
|
365
|
+
if (ciphers === 4 && wpaFlags.indexOf('PSK/AES') === -1) { wpaFlags.push('PSK/AES'); }
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
result.push({
|
|
370
|
+
ssid: wifiItem.SSID_STR,
|
|
371
|
+
bssid: wifiItem.BSSID,
|
|
372
|
+
mode: '',
|
|
373
|
+
channel: wifiItem.CHANNEL,
|
|
374
|
+
frequency: wifiFrequencyFromChannel(wifiItem.CHANNEL),
|
|
375
|
+
signalLevel: signalLevel ? parseInt(signalLevel, 10) : null,
|
|
376
|
+
quality: wifiQualityFromDB(signalLevel),
|
|
377
|
+
security,
|
|
378
|
+
wpaFlags,
|
|
379
|
+
rsnFlags: []
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return result;
|
|
384
|
+
}
|
|
385
|
+
function wifiNetworks(callback) {
|
|
320
386
|
return new Promise((resolve) => {
|
|
321
387
|
process.nextTick(() => {
|
|
322
388
|
let result = [];
|
|
@@ -369,45 +435,10 @@ function wifiNetworks(callback) {
|
|
|
369
435
|
resolve(result);
|
|
370
436
|
}
|
|
371
437
|
} else if (_darwin) {
|
|
372
|
-
let cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s';
|
|
373
|
-
exec(cmd, { maxBuffer: 1024 *
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
const parsedhead = util.parseHead(lines[0], 1);
|
|
377
|
-
if (parsedhead.length >= 7) {
|
|
378
|
-
lines.shift();
|
|
379
|
-
lines.forEach(line => {
|
|
380
|
-
if (line.trim()) {
|
|
381
|
-
const channelStr = line.substring(parsedhead[3].from, parsedhead[3].to).trim();
|
|
382
|
-
const channel = channelStr ? parseInt(channelStr, 10) : null;
|
|
383
|
-
const signalLevel = line.substring(parsedhead[2].from, parsedhead[2].to).trim();
|
|
384
|
-
const securityAll = line.substring(parsedhead[6].from, 1000).trim().split(' ');
|
|
385
|
-
let security = [];
|
|
386
|
-
let wpaFlags = [];
|
|
387
|
-
securityAll.forEach(securitySingle => {
|
|
388
|
-
if (securitySingle.indexOf('(') > 0) {
|
|
389
|
-
const parts = securitySingle.split('(');
|
|
390
|
-
security.push(parts[0]);
|
|
391
|
-
wpaFlags = wpaFlags.concat(parts[1].replace(')', '').split(','));
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
wpaFlags = Array.from(new Set(wpaFlags));
|
|
395
|
-
result.push({
|
|
396
|
-
ssid: line.substring(parsedhead[0].from, parsedhead[0].to).trim(),
|
|
397
|
-
bssid: line.substring(parsedhead[1].from, parsedhead[1].to).trim().toLowerCase(),
|
|
398
|
-
mode: '',
|
|
399
|
-
channel,
|
|
400
|
-
frequency: wifiFrequencyFromChannel(channel),
|
|
401
|
-
signalLevel: signalLevel ? parseInt(signalLevel, 10) : null,
|
|
402
|
-
quality: wifiQualityFromDB(signalLevel),
|
|
403
|
-
security,
|
|
404
|
-
wpaFlags,
|
|
405
|
-
rsnFlags: []
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
}
|
|
438
|
+
let cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s -x';
|
|
439
|
+
exec(cmd, { maxBuffer: 1024 * 40000 }, function (error, stdout) {
|
|
440
|
+
const output = stdout.toString();
|
|
441
|
+
result = parseWifiDarwin(util.plistParser(output));
|
|
411
442
|
if (callback) {
|
|
412
443
|
callback(result);
|
|
413
444
|
}
|
|
@@ -544,7 +575,7 @@ function wifiConnections(callback) {
|
|
|
544
575
|
const noise = util.toInt(util.getValue(lines2, 'agrCtlNoise', ':', true));
|
|
545
576
|
const signalLevel = rssi - noise;
|
|
546
577
|
// const signal = wifiQualityFromDB(signalLevel);
|
|
547
|
-
if (ssid
|
|
578
|
+
if (ssid || bssid) {
|
|
548
579
|
result.push({
|
|
549
580
|
id: 'Wi-Fi',
|
|
550
581
|
iface,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.18",
|
|
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)",
|