From bba585f063ccc1e483346c9b5625d4dcf84d6586 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 27 Apr 2008 16:12:24 +0000 Subject: * Added initial version of RPC info API * Fixed client splash --- contrib/package/ffluci-splash/src/luci-splash.lua | 5 ++--- .../src/luci-splash/htdocs/cgi-bin/index.cgi | 15 ++++++++++++++- contrib/package/ffluci-splash/src/luci_splash.init | 5 +---- 3 files changed, 17 insertions(+), 8 deletions(-) (limited to 'contrib/package/ffluci-splash') diff --git a/contrib/package/ffluci-splash/src/luci-splash.lua b/contrib/package/ffluci-splash/src/luci-splash.lua index 54c32add6d..0699d2820a 100644 --- a/contrib/package/ffluci-splash/src/luci-splash.lua +++ b/contrib/package/ffluci-splash/src/luci-splash.lua @@ -10,7 +10,6 @@ require("ffluci.model.uci") uci = ffluci.model.uci.Session("/var/state") --- Parse stdin and do something function main(argv) local cmd = argv[1] local arg = argv[2] @@ -156,7 +155,7 @@ function sync() local n = uci:add("luci_splash", "lease") uci:set("luci_splash", n, "mac", v.mac) uci:set("luci_splash", n, "start", v.start) - written[v.mac] = 1 + written[v.mac:lower()] = 1 end end end @@ -164,7 +163,7 @@ function sync() -- Delete rules without state for i, r in ipairs(listrules()) do - if #r > 0 and not written[r] then + if #r > 0 and not written[r:lower()] then remove_rule(r) end end diff --git a/contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi b/contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi index 4cbddc0c5b..91a6b3397f 100644 --- a/contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi +++ b/contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi @@ -7,22 +7,35 @@ require("ffluci.sys") require("ffluci.model.uci") local srv +local net local ip = ffluci.http.remote_addr() for k, v in pairs(ffluci.model.uci.show("network").network) do if v[".type"] == "interface" and v.ipaddr then local p = ffluci.sys.net.mask4prefix(v.netmask) if ffluci.sys.net.belongs(ip, v.ipaddr, p) then + net = k srv = v.ipaddr break end end end +local stat = false +for k, v in pairs(ffluci.model.uci.show("luci_splash").luci_splash) do + if v[".type"] == "iface" and v.network == net then + stat = true + end +end + if not srv then ffluci.http.textheader() return print("Unable to detect network settings!") end +if not stat then + ffluci.http.redirect("http://" .. srv) +end + local action = "splash" local mac = ffluci.sys.net.ip4mac(ip) @@ -30,7 +43,7 @@ if not mac then action = "unknown" end -local status = ffluci.sys.exec("luci-splash status "..mac) +local status = ffluci.sys.execl("luci-splash status "..mac)[1] if status == "whitelisted" or status == "lease" then action = "allowed" diff --git a/contrib/package/ffluci-splash/src/luci_splash.init b/contrib/package/ffluci-splash/src/luci_splash.init index a7bb4abeb4..bce432ed30 100644 --- a/contrib/package/ffluci-splash/src/luci_splash.init +++ b/contrib/package/ffluci-splash/src/luci_splash.init @@ -20,7 +20,7 @@ iface_add() { eval "$(ipcalc.sh $ipaddr $netmask)" iptables -t nat -A luci_splash -i "$iface" -s "$IP/$PREFIX" -j luci_splash_portal - iptables -t nat -A luci_splash_portal -i "$iface" -s "$IP/$PREFIX" -d "$ipaddr" -p tcp --dport 80 -j RETURN + iptables -t nat -A luci_splash_portal -i "$iface" -s "$IP/$PREFIX" -d "$ipaddr" -p tcp -m multiport --dports 22,80,443 -j RETURN } blacklist_add() { @@ -64,9 +64,6 @@ start() { ### Start the splash httpd httpd -c /etc/luci_splash_httpd.conf -p 8082 -h /usr/lib/luci-splash/htdocs - ### Sync leases - /usr/lib/luci-splash/sync.lua - ### Hook in the chain iptables -t nat -A prerouting_rule -j luci_splash } -- cgit v1.2.3