1 #!/usr/bin/haserl --shell=luac
2 package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
3 package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
7 require("luci.model.uci")
11 local ip = luci.http.env.REMOTE_ADDR
12 for k, v in pairs(luci.model.uci.sections("network")) do
13 if v[".type"] == "interface" and v.ipaddr then
14 local p = luci.sys.net.mask4prefix(v.netmask)
15 if luci.sys.net.belongs(ip, v.ipaddr, p) then
24 for k, v in pairs(luci.model.uci.sections("luci_splash")) do
25 if v[".type"] == "iface" and v.network == net then
31 luci.http.prepare_content("text/plain")
32 print("Unable to detect network settings!")
34 luci.http.redirect("http://" .. srv)
36 local action = "splash"
38 local mac = luci.sys.net.ip4mac(ip)
43 local status = luci.sys.execl("luci-splash status "..mac)[1]
45 if status == "whitelisted" or status == "lease" then
49 luci.http.redirect("http://" .. srv .. "/cgi-bin/luci-splash/" .. action)