Refactor client tracking in handle_packet to simplify logic and ensure unicast clients are counted correctly, excluding the target AP BSSID.

This commit is contained in:
Yaro Kasear 2025-05-01 10:45:26 -05:00
parent 7d9e33e9ea
commit 021ea90d9a

View file

@ -86,15 +86,18 @@ def handle_packet(pkt):
ssid_map[a2] = ssid
# === Track all seen clients ===
if is_unicast(a1) and a1 not in aps:
clients[a1] += 1
if is_unicast(a2) and a2 not in aps:
clients[a2] += 1
sa = dot11.addr2.lower() if dot11.addr2 else None
da = dot11.addr1.lower() if dot11.addr1 else None
for mac in (sa, da):
if is_unicast(mac) and mac != target_ap_bssid:
clients[mac] += 1
# Track clients talking to the same AP we're connected to
if target_ap_bssid:
if a1 and a2:
if target_ap_bssid in (a1.lower(), a2.lower()):
if target_ap_bssid in (a1, a2):
peer = a2 if a1 == target_ap_bssid else a1
if is_unicast(peer) and peer not in aps:
ap_clients[target_ap_bssid][peer] += 1