treewide: filter shell arguments through shellquote() where applicable
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_network / hosts.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2010-2015 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 local ipc = require "luci.ip"
6 local sys = require "luci.sys"
7
8 m = Map("dhcp", translate("Hostnames"))
9
10 s = m:section(TypedSection, "domain", translate("Host entries"))
11 s.addremove = true
12 s.anonymous = true
13 s.template = "cbi/tblsection"
14
15 hn = s:option(Value, "name", translate("Hostname"))
16 hn.datatype = "hostname"
17 hn.rmempty  = true
18
19 ip = s:option(Value, "ip", translate("IP address"))
20 ip.datatype = "ipaddr"
21 ip.rmempty  = true
22
23 sys.net.host_hints(function(mac, v4, v6, name)
24         v6 = v6 and ipc.IPv6(v6)
25
26         if v4 or (v6 and not v6:is6linklocal()) then
27                 ip:value(tostring(v4 or v6), "%s (%s)" %{ tostring(v4 or v6), name or mac })
28         end
29 end)
30
31 return m