luci-mod-admin-full: add DUID option to static leases section
authorJan Pavlinec <jan.pavlinec@nic.cz>
Wed, 8 Feb 2017 11:54:04 +0000 (12:54 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 10 Nov 2017 12:00:26 +0000 (13:00 +0100)
Signed-off-by: Jan Pavlinec <jan.pavlinec@nic.cz>
[add field validation]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/dhcp.lua

index c7d330e68dd463fe12495d7f112afb3507ebeefa..0c01ceffca24358c9dc7f578740914ec1177e7ea 100644 (file)
@@ -296,6 +296,19 @@ ip.datatype = "or(ip4addr,'ignore')"
 time = s:option(Value, "leasetime", translate("Lease time"))
 time.rmempty  = true
 
+duid = s:option(Value, "duid", translate("<abbr title=\"The DHCP Unique Identifier\">DUID</abbr>"))
+duid.datatype = "and(rangelength(28,36),hexstring)"
+fp = io.open("/var/hosts/odhcpd")
+if fp then
+       for line in fp:lines() do
+               local net_val, duid_val = string.match(line, "# (%S+)%s+(%S+)")
+               if duid_val then
+                       duid:value(duid_val, duid_val)
+               end
+       end
+       fp:close()
+end
+
 hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)"))
 
 ipc.neighbors({ family = 4 }, function(n)