1 package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
2 package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
6 require("ffluci.model.uci")
8 ucis = ffluci.model.uci.Session("/var/state")
10 function add_lease(mac)
11 local key = ucis:add("luci_splash", "lease")
12 ucis:set("luci_splash", key, "mac", mac)
16 function add_rule(mac)
17 return os.execute("iptables -t nat -I luci_splash_leases -m mac --source-mac '"..mac.."' -j RETURN")
20 function remove_rule(mac)
21 return os.execute("iptables -t nat -D luci_splash_leases -m mac --source-mac '"..mac.."' -j RETURN")
24 function get_usermac()
25 local ip = ffluci.http.remote_addr()
28 for i, l in ipairs(ffluci.sys.net.arptable()) do
29 if l["IP address"] == ip then
37 function haslease(mac)
39 local list = ucis:show("luci_splash").luci_splash
41 for k, v in pairs(list) do
42 if v[".type"] == "lease" and v.mac and v.mac:lower() == mac then
50 function isblacklisted(mac)
52 local list = ucis:show("luci_splash").luci_splash
54 for k, v in pairs(list) do
55 if v[".type"] == "blacklist" and v.mac and v.mac:lower() == mac then
63 function iswhitelisted(mac)
65 local list = ucis:show("luci_splash").luci_splash
67 for k, v in pairs(list) do
68 if v[".type"] == "whitelist" and v.mac and v.mac:lower() == mac then