|
@@ -193,6 +193,7 @@ local function get_wifi_clients()
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-- Query each interface separately
|
|
-- Query each interface separately
|
|
|
|
|
+ local count = 0
|
|
|
for _, iface in ipairs(interfaces) do
|
|
for _, iface in ipairs(interfaces) do
|
|
|
local f = io.popen("ubus call " .. iface .. " get_clients 2>/dev/null")
|
|
local f = io.popen("ubus call " .. iface .. " get_clients 2>/dev/null")
|
|
|
if f then
|
|
if f then
|
|
@@ -200,16 +201,21 @@ local function get_wifi_clients()
|
|
|
f:close()
|
|
f:close()
|
|
|
-- Check if there are actually clients (result contains "clients": {})
|
|
-- Check if there are actually clients (result contains "clients": {})
|
|
|
if result:find('"clients"') and not result:find('"clients":%s*{}') then
|
|
if result:find('"clients"') and not result:find('"clients":%s*{}') then
|
|
|
|
|
+ local mac_count = 0
|
|
|
-- Extract MAC addresses - match pattern for valid MACs
|
|
-- Extract MAC addresses - match pattern for valid MACs
|
|
|
for mac in result:gmatch('([a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9])') do
|
|
for mac in result:gmatch('([a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9])') do
|
|
|
-- Validate MAC before adding
|
|
-- Validate MAC before adding
|
|
|
if is_valid_mac(mac) and not clients[mac] then
|
|
if is_valid_mac(mac) and not clients[mac] then
|
|
|
clients[mac] = { iface = iface, ssid = ssid_map[iface] }
|
|
clients[mac] = { iface = iface, ssid = ssid_map[iface] }
|
|
|
|
|
+ mac_count = mac_count + 1
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
+ log_info(iface .. " clients: " .. mac_count)
|
|
|
|
|
+ count = count + mac_count
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
+ log_info("Total WiFi clients: " .. count)
|
|
|
|
|
|
|
|
return clients
|
|
return clients
|
|
|
end
|
|
end
|