Last active
March 16, 2025 13:00
-
-
Save oxavelar/5be72dc2b08f7743c0b46c22f4f7a01f to your computer and use it in GitHub Desktop.
Workaround for mt76: https://github.com/openwrt/mt76/issues/922
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
disconnect() { | |
local dev=$1 | |
local mac=$2 | |
echo "$dev: disconnect $mac" > /dev/kmsg | |
ubus call hostapd.$dev del_client "{'addr':'$mac', 'reason':8, 'deauth':true, 'ban_time':0}" | |
} | |
mt79_rssi_monitor() { | |
local dev=$1 | |
echo "$dev: watchdog [rssi-monitor]" > /dev/kmsg | |
( | |
while true; do | |
sleep 5 | |
stas=$(iw dev "$dev" station dump | awk 'BEGIN {RS="Station"; ORS="\n"} {gsub(/\n\s/, " "); print $0}') | |
noise=$(iwinfo "$dev" info | grep -oE 'Noise:\s(-?[0-9]+)' | awk '{print $2}') | |
echo "${stas}" | while IFS= read -r sta; do | |
if [ -z "$sta" ]; then continue ;fi | |
mac=$(echo "${sta}" | grep -oE '([a-f0-9]{2}:){5}[a-f0-9]{2}') | |
signal=$(echo "${sta}" | grep -oE 'signal:\s*(-?[0-9]+)' | head -n1 | awk '{print $2}') | |
sensed=$(echo "${sta}" | grep -oE 'inactive time:\s*([0-9]+)' | awk '{print $3}') | |
if [ "$signal" -lt "$noise" ] && | |
[ "$sensed" -gt 10000 ] || | |
[ "$sensed" -gt 20000 ]; then | |
disconnect "$dev" "$mac" | |
fi | |
done | |
done | |
) & | |
} | |
# Ensure necessary services are up | |
sleep 40 | |
# Start bogus-client monitoring for APs | |
for dev in $(iwinfo | awk '/phy[0-9]-ap[0-9]/ { print $1 }'); do | |
mt79_rssi_monitor "$dev" & | |
done | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If this is working you should see something like this:
With events following: