From a29c4ce658fbdcc1d507646b14b22de0cf4890fc Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 10 Jul 2009 22:45:50 +0000 Subject: applications/luci-splash: speedup splash dispatching --- .../luci-splash/luasrc/controller/splash/splash.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'applications/luci-splash') diff --git a/applications/luci-splash/luasrc/controller/splash/splash.lua b/applications/luci-splash/luasrc/controller/splash/splash.lua index 2906298f1..362ad9def 100644 --- a/applications/luci-splash/luasrc/controller/splash/splash.lua +++ b/applications/luci-splash/luasrc/controller/splash/splash.lua @@ -11,12 +11,21 @@ function index() end function action_dispatch() + local uci = luci.model.uci.cursor_state() 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 == "new" then - luci.http.redirect(luci.dispatcher.build_url("splash", "splash")) - else + local access = false + + uci:foreach("luci_splash", "lease", function(s) + if s.mac and s.mac:lower() == mac then access = true end + end) + uci:foreach("luci_splash", "whitelist", function(s) + if s.mac and s.mac:lower() == mac then access = true end + end) + + if #mac > 0 and access then luci.http.redirect(luci.dispatcher.build_url()) + else + luci.http.redirect(luci.dispatcher.build_url("splash", "splash")) end end -- cgit v1.2.3