|
@@ -165,17 +165,32 @@ end
|
|
|
local function get_wifi_clients()
|
|
local function get_wifi_clients()
|
|
|
local clients = {}
|
|
local clients = {}
|
|
|
local interfaces = get_hostapd_interfaces()
|
|
local interfaces = get_hostapd_interfaces()
|
|
|
|
|
+
|
|
|
|
|
+ -- Get SSID mapping first
|
|
|
|
|
+ local ssid_map = {}
|
|
|
|
|
+ for _, iface in ipairs(interfaces) do
|
|
|
|
|
+ ssid_map[iface] = get_ssid_name(iface)
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
|
|
+ -- Query each interface separately
|
|
|
for _, iface in ipairs(interfaces) do
|
|
for _, iface in ipairs(interfaces) do
|
|
|
- local ssid = get_ssid_name(iface)
|
|
|
|
|
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
|
|
|
local result = f:read("*a")
|
|
local result = f:read("*a")
|
|
|
f:close()
|
|
f:close()
|
|
|
- for mac in result:gmatch('"([a-fA-F0-9:]+)"') do
|
|
|
|
|
- clients[mac] = { iface = iface, ssid = ssid }
|
|
|
|
|
|
|
+ -- Check if there are actually clients (result contains "clients": {})
|
|
|
|
|
+ if result:find('"clients"') and not result:find('"clients":%s*{}') then
|
|
|
|
|
+ -- 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
|
|
|
|
|
+ -- Only add if not already tracked (first interface wins)
|
|
|
|
|
+ if not clients[mac] then
|
|
|
|
|
+ clients[mac] = { iface = iface, ssid = ssid_map[iface] }
|
|
|
|
|
+ end
|
|
|
|
|
+ end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
+
|
|
|
return clients
|
|
return clients
|
|
|
end
|
|
end
|
|
|
|
|
|