Skip to content

Commit

Permalink
Merge pull request #959 from prey/fix/get-active-access-point
Browse files Browse the repository at this point in the history
fix: get active access point mac fix
  • Loading branch information
beregcamlost authored Mar 19, 2024
2 parents a109f97 + dbd14c3 commit 702e967
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions lib/agent/providers/network/mac.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,29 @@ exports.get_wireless_interfaces_list = (cb) => {

exports.get_active_access_point_mac = (callback) => {
let output;
accessPointsFn(airportCmd, ['-I'], (err, stdoutIn) => {
let stdout = stdoutIn;
if (err) return callback(err);

stdout = stdout.toString().split('\n');
stdout.forEach((line, index) => {
const data = line.split(': ');
if (data[0].trim() === 'BSSID') {
// eslint-disable-next-line prefer-destructuring
output = data[1];
}

if (index === stdout.length - 1) {
return callback(null, output);
}
});
isAirportWorking((itWorks) => {
if (itWorks) {
accessPointsFn(airportCmd, ['-I'], (err, stdoutIn) => {
let stdout = stdoutIn;
if (err) return callback(err);
stdout = stdout.toString().split('\n');
stdout.forEach((line, index) => {
const data = line.split(': ');
if (data[0].trim() === 'BSSID') {
// eslint-disable-next-line prefer-destructuring
output = data[1];
}
if (index === stdout.length - 1) {
return callback(null, output);
}
});
});
} else {
socket.writeMessage('info', (error, apData) => {
if (error) return callback(error);
return callback(null, apData.mac_address);
});
}
});
};

Expand Down

0 comments on commit 702e967

Please sign in to comment.