diff options
author | Steven Barth <steven@midlink.org> | 2008-08-26 23:00:44 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-08-26 23:00:44 +0000 |
commit | 91ba7c42f5b45614c9f4c803d09399f08a8e27b1 (patch) | |
tree | 21d1e1d67b3bee82eb123c0c5dbb274f2fcb6b59 /applications/luci-splash/root | |
parent | 43b3217e5595acc91ff6d7614a5c21c88696fbcc (diff) |
UCI API changes
Diffstat (limited to 'applications/luci-splash/root')
-rwxr-xr-x | applications/luci-splash/root/usr/bin/luci-splashd | 5 | ||||
-rwxr-xr-x | applications/luci-splash/root/usr/sbin/luci-splash | 29 |
2 files changed, 17 insertions, 17 deletions
diff --git a/applications/luci-splash/root/usr/bin/luci-splashd b/applications/luci-splash/root/usr/bin/luci-splashd index 3e0c938eb..267fbdf0a 100755 --- a/applications/luci-splash/root/usr/bin/luci-splashd +++ b/applications/luci-splash/root/usr/bin/luci-splashd @@ -4,7 +4,8 @@ require("socket") require("luci.ip") require("luci.model.uci") -luci.model.uci.load_state("network") +local uci = luci.model.uci.cursor_state() +uci:load("network") local server = socket.bind("0.0.0.0", arg[1] or 8082) server:settimeout(0, "t") @@ -16,7 +17,7 @@ while true do client:settimeout(1) local srv local ip = luci.ip.IPv4(client:getpeername()) - luci.model.uci.foreach("network", "interface", + uci:foreach("network", "interface", function (section) if section.ipaddr then local net = luci.ip.IPv4(section.ipaddr, section.netmask) diff --git a/applications/luci-splash/root/usr/sbin/luci-splash b/applications/luci-splash/root/usr/sbin/luci-splash index 520f87702..82662c871 100755 --- a/applications/luci-splash/root/usr/sbin/luci-splash +++ b/applications/luci-splash/root/usr/sbin/luci-splash @@ -5,8 +5,7 @@ require("luci.util") require("luci.model.uci") -- Init state session -luci.model.uci.load_state("luci_splash") -local uci = luci.model.uci +local uci = luci.model.uci.cursor_state() function main(argv) @@ -60,13 +59,13 @@ end -- Add a lease to state and invoke add_rule function add_lease(mac) - uci.section("luci_splash", "lease", nil, { + uci:section("luci_splash", "lease", nil, { mac = mac, start = os.time() }) add_rule(mac) - uci.save_state("luci_splash") + uci:save("luci_splash") end @@ -75,7 +74,7 @@ function remove_lease(mac) mac = mac:lower() local del = {} - uci.foreach("luci_splash", "lease", + uci:foreach("luci_splash", "lease", function (section) if section.mac:lower() == mac then table.insert(del, section[".name"]) @@ -84,10 +83,10 @@ function remove_lease(mac) for i,j in ipairs(del) do remove_rule(j) - uci.delete("luci_splash", j) + uci:delete("luci_splash", j) end - uci.save_state("luci_splash") + uci:save("luci_splash") end @@ -108,7 +107,7 @@ function haslease(mac) mac = mac:lower() local stat = false - uci.foreach("luci_splash", "lease", + uci:foreach("luci_splash", "lease", function (section) if section.mac:lower() == mac then stat = true @@ -124,7 +123,7 @@ end function iswhitelisted(mac) mac = mac:lower() - uci.foreach("luci_splash", "whitelist", + uci:foreach("luci_splash", "whitelist", function (section) if section.mac:lower() == mac then stat = true @@ -150,14 +149,14 @@ function sync() local time = os.time() -- Current leases in state files - local leases = uci.get_all("luci_splash") + local leases = uci:get_all("luci_splash") -- Convert leasetime to seconds - local leasetime = tonumber(uci.get("luci_splash", "general", "leasetime")) * 3600 + local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime")) * 3600 -- Clean state file - uci.load_state("luci_splash") - uci.revert("luci_splash") + uci:load("luci_splash") + uci:revert("luci_splash") -- For all leases @@ -168,7 +167,7 @@ function sync() remove_rule(v.mac) else -- Rewrite state - uci.section("luci_splash", "lease", nil, { + uci:section("luci_splash", "lease", nil, { mac = v.mac, start = v.start }) @@ -185,7 +184,7 @@ function sync() end end - uci.save_state("luci_splash") + uci:save("luci_splash") end main(arg)
\ No newline at end of file |