summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua')
-rw-r--r--modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua38
1 files changed, 35 insertions, 3 deletions
diff --git a/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua b/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua
index 3d26d6a9d6..85b2c86aad 100644
--- a/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua
+++ b/modules/admin-mini/luasrc/model/cbi/mini/dhcp.lua
@@ -14,6 +14,7 @@ $Id$
]]--
require("luci.model.uci")
require("luci.sys")
+require("luci.tools.webadmin")
m = Map("dhcp", "DHCP")
@@ -21,7 +22,7 @@ s = m:section(TypedSection, "dhcp", "DHCP-Server")
s.anonymous = true
s:depends("interface", "lan")
-enable = s:option(ListValue, "ignore", "", "")
+enable = s:option(ListValue, "ignore", translate("enable"), "")
enable:value(0, translate("enable"))
enable:value(1, translate("disable"))
@@ -52,9 +53,40 @@ time = s:option(Value, "leasetime")
time:depends("ignore", "0")
time.rmempty = true
-m2 = Map("luci_ethers", translate("luci_ethers"))
-s = m2:section(TypedSection, "static_lease", "")
+
+m2 = Map("luci_ethers", translate("dhcp_leases"))
+
+local leasefn, leasefp, leases
+luci.model.uci.foreach("dhcp", "dnsmasq",
+ function(section)
+ leasefn = section.leasefile
+ end
+)
+local leasefp = leasefn and luci.fs.access(leasefn) and io.lines(leasefn)
+if leasefp then
+ leases = {}
+ for lease in leasefp do
+ table.insert(leases, luci.util.split(lease, " "))
+ end
+end
+
+if leases then
+ v = m2:section(Table, leases, translate("dhcp_leases_active"))
+ ip = v:option(DummyValue, 3, translate("ipaddress"))
+
+ mac = v:option(DummyValue, 2, translate("macaddress"))
+
+ ltime = v:option(DummyValue, 1, translate("dhcp_timeremain"))
+ function ltime.cfgvalue(self, ...)
+ local value = DummyValue.cfgvalue(self, ...)
+ return luci.tools.webadmin.date_format(
+ os.difftime(tonumber(value), os.time())
+ )
+ end
+end
+
+s = m2:section(TypedSection, "static_lease", translate("luci_ethers"))
s.addremove = true
s.anonymous = true
s.template = "cbi/tblsection"