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("ffluci.model.uci")
11 local ip = ffluci.http.remote_addr()
12 for k, v in pairs(ffluci.model.uci.sections("network")) do
13 if v[".type"] == "interface" and v.ipaddr then
14 local p = ffluci.sys.net.mask4prefix(v.netmask)
15 if ffluci.sys.net.belongs(ip, v.ipaddr, p) then
24 for k, v in pairs(ffluci.model.uci.sections("luci_splash")) do
25 if v[".type"] == "iface" and v.network == net then
31 ffluci.http.textheader()
32 return print("Unable to detect network settings!")
36 ffluci.http.redirect("http://" .. srv)
39 local action = "splash"
41 local mac = ffluci.sys.net.ip4mac(ip)
46 local status = ffluci.sys.execl("luci-splash status "..mac)[1]
48 if status == "whitelisted" or status == "lease" then
52 ffluci.http.redirect("http://" .. srv .. "/cgi-bin/luci-splash/" .. action)