wifiConnections() added patch for deprecated airport cmd (macOS Sonoma 14.1)
This commit is contained in:
parent
9d852bcc88
commit
400b231406
44
lib/wifi.js
44
lib/wifi.js
@ -540,6 +540,11 @@ function getVendor(model) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function formatBssid(s) {
|
||||
s = s.replace(/</g, '').replace(/>/g, '').match(/.{1,2}/g);
|
||||
return s.join(':');
|
||||
}
|
||||
|
||||
function wifiConnections(callback) {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
@ -606,12 +611,17 @@ function wifiConnections(callback) {
|
||||
const lines = parts1[1].split('\n\n')[0].split('\n');
|
||||
const iface = util.getValue(lines, 'BSD Device Name', ':', true);
|
||||
const model = util.getValue(lines, 'hardware', ':', true);
|
||||
cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I';
|
||||
cmd = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I 2>/dev/null; echo "######" ; ioreg -n AppleBCMWLANSkywalkInterface -r 2>/dev/null';
|
||||
exec(cmd, function (error, stdout) {
|
||||
const lines2 = stdout.toString().split('\n');
|
||||
if (lines.length > 10) {
|
||||
const parts = stdout.toString().split('######');
|
||||
const lines2 = parts[0].split('\n');
|
||||
let lines3 = [];
|
||||
if (parts[1].indexOf(' | {') > 0 && parts[1].indexOf(' | }') > parts[1].indexOf(' | {')) {
|
||||
lines3 = parts[1].split(' | {')[1].split(' | }')[0].replace(/ \| /g, '').replace(/"/g, '').split('\n');
|
||||
}
|
||||
if (lines2.length > 10) {
|
||||
const ssid = util.getValue(lines2, 'ssid', ':', true);
|
||||
const bssid = util.getValue(lines2, 'bssid', ':', true);
|
||||
const bssid = util.getValue(lines2, 'bssid', ':', true) || formatBssid(util.getValue(lines3, 'IO80211BSSID', '=', true));;
|
||||
const security = util.getValue(lines2, 'link auth', ':', true);
|
||||
const txRate = util.getValue(lines2, 'lastTxRate', ':', true);
|
||||
const channel = util.getValue(lines2, 'channel', ':', true).split(',')[0];
|
||||
@ -636,6 +646,32 @@ function wifiConnections(callback) {
|
||||
});
|
||||
}
|
||||
}
|
||||
if (lines3.length > 10) {
|
||||
const ssid = util.getValue(lines3, 'IO80211SSID', '=', true);
|
||||
const bssid = formatBssid(util.getValue(lines3, 'IO80211BSSID', '=', true));
|
||||
const security = '';
|
||||
const txRate = -1;
|
||||
const signalLevel = -1;
|
||||
const quality = -1;
|
||||
const channel = util.getValue(lines3, 'IO80211Channel', '=', true);
|
||||
const type = '802.11';
|
||||
if ((ssid || bssid) && !result.length) {
|
||||
result.push({
|
||||
id: 'Wi-Fi',
|
||||
iface,
|
||||
model,
|
||||
ssid,
|
||||
bssid,
|
||||
channel: util.toInt(channel),
|
||||
frequency: channel ? wifiFrequencyFromChannel(channel) : null,
|
||||
type,
|
||||
security,
|
||||
signalLevel,
|
||||
quality,
|
||||
txRate
|
||||
});
|
||||
}
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user