Merge pull request #15 from soitgoes/master

Accomodate for apples elimination of BSSID from airport results
This commit is contained in:
Christian Kuster 2023-01-24 21:24:15 +01:00 committed by GitHub
commit 36e1f8ffaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 14 deletions

View File

@ -7,8 +7,6 @@ const tool = '/System/Library/PrivateFrameworks/Apple80211.framework/Version
const cmdLine = tool + ' -s'; const cmdLine = tool + ' -s';
const detector = tool + ' -getInfo'; const detector = tool + ' -getInfo';
const macRegex = /([0-9a-zA-Z]{1}[0-9a-zA-Z]{1}[:]{1}){5}[0-9a-zA-Z]{1}[0-9a-zA-Z]{1}/;
/** /**
* Parsing the output of airport (Mac OS X) * Parsing the output of airport (Mac OS X)
* @param str output of the tool * @param str output of the tool
@ -22,17 +20,13 @@ function parseOutput(str, callback) {
let lines = str.split('\n'); let lines = str.split('\n');
for (let i = 1, l = lines.length; i < l; i++) { for (let i = 1, l = lines.length; i < l; i++) {
let mac = lines[i].match(macRegex); if (lines[i] == '') continue;
if (!mac) { let elements = lines[i].substr(51).split(/[ ]+/);
continue;
}
let macStart = lines[i].indexOf(mac[0]);
let elements = lines[i].substr(macStart).split(/[ ]+/);
wifis.push({ wifis.push({
'ssid' : lines[i].substr(0, macStart).trim(), 'ssid' : lines[i].substr(0,32).trim(),
'mac' : elements[0].trim(), 'mac' : lines[i].substr(33,17).trim(),
'channel': parseInt(elements[2].trim(), 10), 'channel': parseInt(elements[1].trim(), 10),
'rssi' : parseInt(elements[1].trim(), 10) 'rssi' : parseInt(elements[0].trim(), 10)
}); });
} }
} }

View File

@ -17,7 +17,7 @@ describe('airport', () => {
assert.equal(info.length, 36); assert.equal(info.length, 36);
let ap = info[0]; let ap = info[0];
assert.equal(ap.mac, '00:35:1a:90:56:03'); assert.equal(ap.mac, '');
assert.equal(ap.ssid, 'OurTest'); assert.equal(ap.ssid, 'OurTest');
assert.equal(ap.rssi, -70); assert.equal(ap.rssi, -70);
assert.strictEqual(ap.channel, 112); assert.strictEqual(ap.channel, 112);

View File

@ -1,5 +1,5 @@
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group) SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
OurTest 00:35:1a:90:56:03 -70 112 Y CH WPA2(PSK/AES/AES) OurTest -70 112 Y CH WPA2(PSK/AES/AES)
OurDev 00:35:1a:90:56:04 -70 112 Y CH WPA2(PSK/AES/AES) OurDev 00:35:1a:90:56:04 -70 112 Y CH WPA2(PSK/AES/AES)
PDANet1 00:35:1a:90:56:09 -70 112 Y CH WPA2(PSK/AES/AES) PDANet1 00:35:1a:90:56:09 -70 112 Y CH WPA2(PSK/AES/AES)
TEST-Wifi 00:35:1a:90:56:0f -70 112 Y CH WPA2(PSK/AES/AES) TEST-Wifi 00:35:1a:90:56:0f -70 112 Y CH WPA2(PSK/AES/AES)