diff options
author | Steven Barth <steven@midlink.org> | 2008-05-06 14:28:51 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-05-06 14:28:51 +0000 |
commit | 6a1fee5115cdf047a29812dcf81b03edeefccb15 (patch) | |
tree | ef1a698180652fb236610850c514e1abcf110f4d /contrib | |
parent | 522c6c928e36db9b5243681fb16f751451ad473a (diff) |
* Rewrote and optimized ffluci.model.uci
* Use optimized UCI code for ffluci.cbi and ffluci.controller.admin.index if possible
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/package/ffluci-splash/src/luci-splash.lua | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/contrib/package/ffluci-splash/src/luci-splash.lua b/contrib/package/ffluci-splash/src/luci-splash.lua index 1520491e0..2fa6bdd4a 100644 --- a/contrib/package/ffluci-splash/src/luci-splash.lua +++ b/contrib/package/ffluci-splash/src/luci-splash.lua @@ -72,7 +72,7 @@ end function remove_lease(mac) mac = mac:lower() - for k, v in pairs(uci:show("luci_splash").luci_splash) do + for k, v in pairs(uci:sections("luci_splash")) do if v[".type"] == "lease" and v.mac:lower() == mac then remove_rule(mac) uci:del("luci_splash", k) @@ -97,7 +97,7 @@ end function haslease(mac) mac = mac:lower() - for k, v in pairs(uci:show("luci_splash").luci_splash) do + for k, v in pairs(uci:sections("luci_splash")) do if v[".type"] == "lease" and v.mac and v.mac:lower() == mac then return true end @@ -111,7 +111,7 @@ end function iswhitelisted(mac) mac = mac:lower() - for k, v in pairs(uci:show("luci_splash").luci_splash) do + for k, v in pairs(uci:sections("luci_splash")) do if v[".type"] == "whitelist" and v.mac and v.mac:lower() == mac then return true end @@ -134,14 +134,16 @@ function sync() local written = {} local time = os.time() + uci:t_load("luci_splash") + -- Current leases in state files - local leases = uci:show("luci_splash").luci_splash + local leases = uci:t_sections("luci_splash") -- Convert leasetime to seconds - local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime")) * 3600 + local leasetime = tonumber(uci:t_get("luci_splash", "general", "leasetime")) * 3600 -- Clean state file - uci:revert("luci_splash") + uci:t_revert("luci_splash") -- For all leases @@ -152,9 +154,9 @@ function sync() remove_rule(v.mac) else -- Rewrite state - local n = uci:add("luci_splash", "lease") - uci:set("luci_splash", n, "mac", v.mac) - uci:set("luci_splash", n, "start", v.start) + local n = uci:t_add("luci_splash", "lease") + uci:t_set("luci_splash", n, "mac", v.mac) + uci:t_set("luci_splash", n, "start", v.start) written[v.mac:lower()] = 1 end end @@ -167,6 +169,8 @@ function sync() remove_rule(r) end end + + uci:t_save("luci_splash") end main(arg)
\ No newline at end of file |