mirror of
https://github.com/smittix/intercept.git
synced 2026-06-08 14:11:54 -07:00
Filter WiFi connected clients by selected access point
The /wifi/v2/clients endpoint was returning all clients regardless of query parameters, because a duplicate route in wifi.py took precedence over the filtered one in wifi_v2.py. Added bssid, associated, and min_rssi filtering to the active route. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+23
-1
@@ -1240,10 +1240,32 @@ def v2_get_networks():
|
||||
|
||||
@wifi_bp.route('/v2/clients')
|
||||
def v2_get_clients():
|
||||
"""Get all discovered clients."""
|
||||
"""Get discovered clients with optional filtering."""
|
||||
try:
|
||||
scanner = get_wifi_scanner()
|
||||
clients = scanner.clients
|
||||
|
||||
# Filter by association status
|
||||
associated = request.args.get('associated')
|
||||
if associated == 'true':
|
||||
clients = [c for c in clients if c.is_associated]
|
||||
elif associated == 'false':
|
||||
clients = [c for c in clients if not c.is_associated]
|
||||
|
||||
# Filter by associated BSSID
|
||||
bssid = request.args.get('bssid')
|
||||
if bssid:
|
||||
clients = [c for c in clients if c.associated_bssid == bssid.upper()]
|
||||
|
||||
# Filter by minimum RSSI
|
||||
min_rssi = request.args.get('min_rssi')
|
||||
if min_rssi:
|
||||
try:
|
||||
min_rssi = int(min_rssi)
|
||||
clients = [c for c in clients if c.rssi_current and c.rssi_current >= min_rssi]
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return jsonify({
|
||||
'clients': [c.to_dict() for c in clients],
|
||||
'total': len(clients),
|
||||
|
||||
Reference in New Issue
Block a user