Fix null error; Fix promise

This commit is contained in:
2024-03-27 22:16:56 +01:00
parent 4e8c3efe6f
commit debd06f258
4 changed files with 19 additions and 7 deletions

View File

@ -13,6 +13,7 @@ const detector = tool + ' --help';
const macRegex = /([0-9a-zA-Z]{1}[0-9a-zA-Z]{1}[:]{1}){5}[0-9a-zA-Z]{1}[0-9a-zA-Z]{1}/;
const cellRegex = /Cell [0-9]{2,} - Address:/;
const encryptedRegex = /Encryption key:on/g;
/**
* Parsing the output of iwlist, tool having a lot of different faces :-(
@ -27,7 +28,8 @@ function parseOutput(str, callback) {
let blocks = str.split(cellRegex);
blocks.forEach(block => {
let network = {};
let network = {encrypted: encryptedRegex.test(block)};
let lines = block.split('\n');
if (macRegex.exec(lines[0])) {
// First line is the mac address (always! (?))