applications/luci-splash: fix mac status query
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 9 Jul 2009 16:55:41 +0000 (16:55 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 9 Jul 2009 16:55:41 +0000 (16:55 +0000)
applications/luci-splash/luasrc/controller/splash/splash.lua
applications/luci-splash/root/usr/sbin/luci-splash

index 13f9f41..3519a03 100644 (file)
@@ -12,8 +12,8 @@ end
 
 function action_dispatch()
        local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or ""
 
 function action_dispatch()
        local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or ""
-       local status = luci.util.execl("luci-splash status "..mac)[1]
-       if #mac > 0 and ( status == "whitelisted" or status == "lease" ) then
+       local status = luci.util.execl("luci-splash status " .. mac)[1]
+       if #mac > 0 and ( status == "whitelist" or status == "lease" ) then
                luci.http.redirect(luci.dispatcher.build_url())
        else
                luci.http.redirect(luci.dispatcher.build_url("splash", "splash"))
                luci.http.redirect(luci.dispatcher.build_url())
        else
                luci.http.redirect(luci.dispatcher.build_url("splash", "splash"))
index 017cfeb..1adcb09 100755 (executable)
@@ -29,7 +29,7 @@ function main(argv)
        limit_down = tonumber(uci:get("luci_splash", "general", "limit_down")) or 0
 
        if ( cmd == "lease" or cmd == "add-rules" or cmd == "remove" or
        limit_down = tonumber(uci:get("luci_splash", "general", "limit_down")) or 0
 
        if ( cmd == "lease" or cmd == "add-rules" or cmd == "remove" or
-            cmd == "whitelist" or cmd == "blacklist" ) and #argv > 0
+            cmd == "whitelist" or cmd == "blacklist" or cmd == "status" ) and #argv > 0
        then
                lock()
 
        then
                lock()
 
@@ -59,6 +59,11 @@ function main(argv)
                                elseif whitelist_macs[mac] then
                                        add_whitelist_rule(mac)
                                end
                                elseif whitelist_macs[mac] then
                                        add_whitelist_rule(mac)
                                end
+                       elseif mac and cmd == "status" then
+                               print(leased_macs[mac] and "lease"
+                                       or whitelist_macs[mac] and "whitelist"
+                                       or blacklist_macs[mac] and "blacklist"
+                                       or "new")
                        elseif mac and ( cmd == "whitelist" or cmd == "blacklist" or cmd == "lease" ) then
                                if cmd ~= "lease" and leased_macs[mac] then
                                        print("Removing %s from leases" % mac)
                        elseif mac and ( cmd == "whitelist" or cmd == "blacklist" or cmd == "lease" ) then
                                if cmd ~= "lease" and leased_macs[mac] then
                                        print("Removing %s from leases" % mac)