summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-splash/luasrc/view
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-splash/luasrc/view')
-rw-r--r--applications/luci-app-splash/luasrc/view/admin_status/splash.htm65
1 files changed, 25 insertions, 40 deletions
diff --git a/applications/luci-app-splash/luasrc/view/admin_status/splash.htm b/applications/luci-app-splash/luasrc/view/admin_status/splash.htm
index 3415c205d5..37f67776aa 100644
--- a/applications/luci-app-splash/luasrc/view/admin_status/splash.htm
+++ b/applications/luci-app-splash/luasrc/view/admin_status/splash.htm
@@ -6,6 +6,8 @@
<%-
local utl = require "luci.util"
+local sys = require "luci.sys"
+local ipc = require "luci.ip"
local ipt = require "luci.sys.iptparser".IptParser()
local uci = require "luci.model.uci".cursor_state()
local wat = require "luci.tools.webadmin"
@@ -14,21 +16,15 @@ local fs = require "nixio.fs"
local clients = { }
local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime") or 1) * 60 * 60
-local leasefile = "/tmp/dhcp.leases"
-
-uci:foreach("dhcp", "dnsmasq",
- function(s)
- if s.leasefile then leasefile = s.leasefile end
- end)
-
uci:foreach("luci_splash_leases", "lease",
function(s)
- if s.start and s.mac then
- clients[s.mac:lower()] = {
+ local m = ipc.checkmac(s.mac)
+ if m and s.start then
+ clients[m] = {
start = tonumber(s.start),
limit = ( tonumber(s.start) + leasetime ),
- mac = s.mac:upper(),
+ mac = m,
ipaddr = s.ipaddr,
policy = "normal",
packets = 0,
@@ -39,11 +35,12 @@ uci:foreach("luci_splash_leases", "lease",
for _, r in ipairs(ipt:find({table="nat", chain="luci_splash_leases"})) do
if r.options and #r.options >= 2 and r.options[1] == "MAC" then
- if not clients[r.options[2]:lower()] then
- clients[r.options[2]:lower()] = {
+ local m = ipc.checkmac(r.options[2])
+ if m and not clients[m] then
+ clients[m] = {
start = 0,
limit = 0,
- mac = r.options[2]:upper(),
+ mac = m,
policy = ( r.target == "RETURN" ) and "whitelist" or "blacklist",
packets = 0,
bytes = 0
@@ -60,7 +57,7 @@ for mac, client in pairs(clients) do
if client.ipaddr then
local rin = ipt:find({table="mangle", chain="luci_splash_mark_in", destination=client.ipaddr})
- local rout = ipt:find({table="mangle", chain="luci_splash_mark_out", options={"MAC", client.mac:upper()}})
+ local rout = ipt:find({table="mangle", chain="luci_splash_mark_out", options={"MAC", client.mac}})
if rin and #rin > 0 then
client.bytes_in = rin[1].bytes
@@ -76,39 +73,27 @@ end
uci:foreach("luci_splash", "whitelist",
function(s)
- if s.mac and clients[s.mac:lower()] then
- clients[s.mac:lower()].policy="whitelist"
+ local m = ipc.checkmac(s.mac)
+ if m and clients[m] then
+ clients[m].policy="whitelist"
end
end)
uci:foreach("luci_splash", "blacklist",
function(s)
- if s.mac and clients[s.mac:lower()] then
- clients[s.mac:lower()].policy=(s.kicked and "kicked" or "blacklist")
+ local m = ipc.checkmac(s.mac)
+ if m and clients[m] then
+ clients[m].policy=(s.kicked and "kicked" or "blacklist")
end
end)
-if fs.access(leasefile) then
- for l in io.lines(leasefile) do
- local time, mac, ip, name = l:match("^(%d+) (%S+) (%S+) (%S+)")
- if time and mac and ip then
- local c = clients[mac:lower()]
- if c then
- c.ip = ip
- c.hostname = ( name ~= "*" ) and name or nil
- end
- end
+sys.net.host_hints(function(mac, v4, v6, name)
+ local c = mac and clients[mac]
+ if c then
+ c.ip = c.ip or v4
+ c.hostname = c.hostname or name
end
-end
-
-for i, n in ipairs(ipc.neighbors({ family = 4 })) do
- if n.mac and n.dest then
- local c = clients[n.mac]
- if c and not c.ip then
- c.ip = n.dest:string()
- end
- end
-end
+end)
local function showmac(mac)
if not is_admin then
@@ -176,7 +161,7 @@ end
splash.hostname, splash.ip, splash.mac, splash.timeleft, splash.trafficin, splash.trafficout);
<% if is_admin then %>
- s += String.format('<select name="policy.%s" style="width:200px">', splash.mac.toLowerCase());
+ s += String.format('<select name="policy.%s" style="width:200px">', splash.mac);
if (splash.policy == 'whitelist') {
s += '<option value="whitelist" selected="selected"><%:whitelisted%></option>'
} else {
@@ -196,7 +181,7 @@ end
s += String.format(
'</select>' +
'<input type="submit" class="cbi-button cbi-button-save" name="save.%s" value="<%:Save%>" />',
- splash.mac.toLowerCase());
+ splash.mac);
<% else %>
s += String.format('%s', splash.policy);
<% end %>