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
-- 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
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)
return false
end)
- uci:save("luci_splash")
+ uci:save("luci_splash_leases")
end
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
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
end
end
- uci:save("luci_splash")
+ uci:save("luci_splash_leases")
-- Get current IPs and MAC addresses
local macs = get_known_macs()
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",