|
@@ -18,6 +18,24 @@ local function http_post(event_type, data)
|
|
|
local f = io.popen("curl -s -X POST '" .. cfg.server_url .. "/api/events' -H 'Content-Type: application/json' -d '" .. json .. "'", "r")
|
|
local f = io.popen("curl -s -X POST '" .. cfg.server_url .. "/api/events' -H 'Content-Type: application/json' -d '" .. json .. "'", "r")
|
|
|
local result = f:read("*a")
|
|
local result = f:read("*a")
|
|
|
f:close()
|
|
f:close()
|
|
|
|
|
+end
|
|
|
|
|
+
|
|
|
|
|
+-- Validate MAC address (proper format with valid hex)
|
|
|
|
|
+local function is_valid_mac(mac)
|
|
|
|
|
+ if not mac or #mac ~= 17 then return false end
|
|
|
|
|
+ local parts = {}
|
|
|
|
|
+ for part in mac:gmatch("[a-fA-F0-9][a-fA-F0-9]") do
|
|
|
|
|
+ table.insert(parts, part)
|
|
|
|
|
+ end
|
|
|
|
|
+ if #parts ~= 6 then return false end
|
|
|
|
|
+ -- First byte: not 00 or FF
|
|
|
|
|
+ local first = tonumber(parts[1], 16)
|
|
|
|
|
+ if first == 0 or first == 255 then return false end
|
|
|
|
|
+ -- Second byte: not FF (multicast)
|
|
|
|
|
+ local second = tonumber(parts[2], 16)
|
|
|
|
|
+ if second == 255 then return false end
|
|
|
|
|
+ return true
|
|
|
|
|
+end
|
|
|
return result
|
|
return result
|
|
|
end
|
|
end
|
|
|
|
|
|
|
@@ -165,24 +183,6 @@ end
|
|
|
|
|
|
|
|
-- Get clients from ALL interfaces WITH their SSID
|
|
-- Get clients from ALL interfaces WITH their SSID
|
|
|
-- Validate MAC address (proper format with valid hex)
|
|
-- Validate MAC address (proper format with valid hex)
|
|
|
-local function is_valid_mac(mac)
|
|
|
|
|
- if not mac or #mac ~= 17 then return false end
|
|
|
|
|
- -- Check format XX:XX:XX:XX:XX:XX
|
|
|
|
|
- local parts = {}
|
|
|
|
|
- for part in mac:gmatch("[a-fA-F0-9][a-fA-F0-9]") do
|
|
|
|
|
- table.insert(parts, part)
|
|
|
|
|
- end
|
|
|
|
|
- -- Must have exactly 6 parts
|
|
|
|
|
- if #parts ~= 6 then return false end
|
|
|
|
|
- -- First byte must not be 00 or FF (invalid/broadcast)
|
|
|
|
|
- local first = tonumber(parts[1], 16)
|
|
|
|
|
- if first == 0 or first == 255 then return false end
|
|
|
|
|
- -- Second byte must not be FF (multicast/broadcast address)
|
|
|
|
|
- local second = tonumber(parts[2], 16)
|
|
|
|
|
- if second == 255 then return false end
|
|
|
|
|
- return true
|
|
|
|
|
-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()
|