diff options
Diffstat (limited to 'applications/luci-splash/root')
-rw-r--r-- | applications/luci-splash/root/etc/config/luci_splash_leases | 1 | ||||
-rwxr-xr-x | applications/luci-splash/root/usr/sbin/luci-splash | 22 |
2 files changed, 12 insertions, 11 deletions
diff --git a/applications/luci-splash/root/etc/config/luci_splash_leases b/applications/luci-splash/root/etc/config/luci_splash_leases new file mode 100644 index 0000000000..6afdd90ede --- /dev/null +++ b/applications/luci-splash/root/etc/config/luci_splash_leases @@ -0,0 +1 @@ +# This file should always stay empty and is just needed to be able to use this config in /var/state! diff --git a/applications/luci-splash/root/usr/sbin/luci-splash b/applications/luci-splash/root/usr/sbin/luci-splash index 34b2e9c420..e4fa6e7750 100755 --- a/applications/luci-splash/root/usr/sbin/luci-splash +++ b/applications/luci-splash/root/usr/sbin/luci-splash @@ -149,7 +149,7 @@ function get_known_macs(list) local leased_macs = { } if not list or list == "lease" then - uci:foreach("luci_splash", "lease", + uci:foreach("luci_splash_leases", "lease", function(s) leased_macs[s.mac:lower()] = true end) end @@ -231,12 +231,12 @@ function add_lease(mac, arp, no_uci) -- Add lease if there is an ip addr if ipaddr then if not no_uci then - uci:section("luci_splash", "lease", convert_mac_to_secname(mac), { + uci:section("luci_splash_leases", "lease", convert_mac_to_secname(mac), { mac = mac, ipaddr = ipaddr, start = os.time() }) - uci:save("luci_splash") + uci:save("luci_splash_leases") end add_lease_rule(mac, ipaddr) else @@ -249,7 +249,7 @@ end function remove_lease(mac) mac = mac:lower() - uci:delete_all("luci_splash", "lease", + uci:delete_all("luci_splash_leases", "lease", function(s) if s.mac:lower() == mac then remove_lease_rule(mac, s.ipaddr) @@ -258,7 +258,7 @@ function remove_lease(mac) return false end) - uci:save("luci_splash") + uci:save("luci_splash_leases") end @@ -363,14 +363,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_leases") -- Convert leasetime to seconds local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime")) * 3600 -- Clean state file - uci:load("luci_splash") - uci:revert("luci_splash") + uci:load("luci_splash_leases") + uci:revert("luci_splash_leases") -- For all leases for k, v in pairs(leases) do @@ -380,7 +380,7 @@ function sync() remove_lease_rule(v.mac, v.ipaddr) else -- Rewrite state - uci:section("luci_splash", "lease", convert_mac_to_secname(v.mac), { + uci:section("luci_splash_leases", "lease", convert_mac_to_secname(v.mac), { mac = v.mac, ipaddr = v.ipaddr, start = v.start @@ -389,7 +389,7 @@ function sync() end end - uci:save("luci_splash") + uci:save("luci_splash_leases") -- Get current IPs and MAC addresses local macs = get_known_macs() @@ -441,7 +441,7 @@ function list() end -- Print listings - local leases = uci:get_all("luci_splash") + local leases = uci:get_all("luci_splash_leases") print(string.format( "%-17s %-15s %-9s %-4s %-7s %20s", |