1 #!/usr/bin/haserl --shell=luac
5 require("luci.model.uci")
7 luci.model.uci.set_savedir(luci.model.uci.savedir_state)
11 local ip = luci.http.env.REMOTE_ADDR
12 luci.model.uci.foreach("network", "interface",
14 if section.ipaddr then
15 local p = luci.sys.net.mask4prefix(section.netmask)
16 if luci.sys.net.belongs(ip, section.ipaddr, p) then
17 net = section[".name"]
25 luci.model.uci.foreach("luci_splash", "iface",
27 if section.network == net then
33 luci.http.prepare_content("text/plain")
34 print("Unable to detect network settings!")
36 luci.http.redirect("http://" .. srv)
38 local action = "splash"
40 local mac = luci.sys.net.ip4mac(ip)
45 local status = luci.sys.execl("luci-splash status "..mac)[1]
47 if status == "whitelisted" or status == "lease" then
51 luci.http.redirect("http://" .. srv .. "/cgi-bin/luci-splash/" .. action)