Merge pull request #1364 from TDT-GmbH/luci-app-mwan3_fixes
[project/luci.git] / applications / luci-app-unbound / luasrc / model / cbi / unbound.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
3 -- Copyright 2016 Dan Luedtke <mail@danrl.com>
4 -- Licensed to the public under the Apache License 2.0.
5
6 local m
7 local s1
8 local ena, mcf, lsv, rlh, rpv, vld, nvd, eds, prt, tlm
9 local ctl, dlk, dom, dty, lfq, wfq, exa, ctl, d64, pfx, qry, qrs
10 local pro, tgr, rsc, rsn, ag2
11
12 m = Map("unbound", translate("Recursive DNS"),
13   translatef("<a href=\"%s\" target=\"_blank\">Unbound</a>"
14   .. " is a validating, recursive, and caching DNS resolver. "
15   .. "UCI help can be found on "
16   .. "<a href=\"%s\" target=\"_blank\">github</a>.",
17   "https://www.unbound.net/",
18   "https://github.com/openwrt/packages/blob/master/net/unbound/files/README.md"))
19
20
21 s1 = m:section(TypedSection, "unbound")
22 s1.addremove = false
23 s1.anonymous = true
24 s1:tab("service", translate("Basic Settings"))
25 s1:tab("advanced", translate("Advanced Settings"))
26 s1:tab("resource", translate("Resource Settings"))
27
28 --LuCI or Not
29
30 ena = s1:taboption("service", Flag, "enabled", translate("Enable Unbound:"),
31   translate("Enable the initialization scripts for Unbound"))
32 ena.rmempty = false
33
34 mcf = s1:taboption("service", Flag, "manual_conf", translate("Manual Conf:"),
35   translate("Skip UCI and use /etc/unbound/unbound.conf"))
36 mcf.rmempty = false
37
38 function ena.cfgvalue(self, section)
39   return luci.sys.init.enabled("unbound") and self.enabled or self.disabled
40 end
41
42 function ena.write(self, section, value)
43   if value == "1" then
44     luci.sys.init.enable("unbound")
45     luci.sys.call("/etc/init.d/unbound start >/dev/null")
46   else
47     luci.sys.call("/etc/init.d/unbound stop >/dev/null")
48     luci.sys.init.disable("unbound")
49   end
50
51   return Flag.write(self, section, value)
52 end
53
54 --Basic Tab
55
56 lsv = s1:taboption("service", Flag, "localservice", translate("Local Service:"),
57   translate("Accept queries only from local subnets"))
58 lsv.rmempty = false
59
60 rlh = s1:taboption("service", Flag, "rebind_localhost", translate("Block Localhost Rebind:"),
61   translate("Prevent upstream response of 127.0.0.0/8"))
62 rlh.rmempty = false
63
64 rpv = s1:taboption("service", Flag, "rebind_protection", translate("Block Private Rebind:"),
65   translate("Prevent upstream response of RFC1918 ranges"))
66 rpv.rmempty = false
67
68 vld = s1:taboption("service", Flag, "validator", translate("Enable DNSSEC:"),
69   translate("Enable the DNSSEC validator module"))
70 vld.rmempty = false
71
72 nvd = s1:taboption("service", Flag, "validator_ntp", translate("DNSSEC NTP Fix:"),
73   translate("Break the loop where DNSSEC needs NTP and NTP needs DNS"))
74 nvd.rmempty = false
75 nvd:depends({ validator = true })
76
77 eds = s1:taboption("service", Value, "edns_size", translate("EDNS Size:"),
78   translate("Limit extended DNS packet size"))
79 eds.datatype = "and(uinteger,min(512),max(4096))"
80 eds.rmempty = false
81
82 prt = s1:taboption("service", Value, "listen_port", translate("Listening Port:"),
83   translate("Choose Unbounds listening port"))
84 prt.datatype = "port"
85 prt.rmempty = false
86
87 tlm = s1:taboption("service", Value, "ttl_min", translate("TTL Minimum:"),
88   translate("Prevent excessively short cache periods"))
89 tlm.datatype = "and(uinteger,min(0),max(600))"
90 tlm.rmempty = false
91
92 --Advanced Tab
93
94 ctl = s1:taboption("advanced", Flag, "unbound_control", translate("Unbound Control App:"),
95   translate("Enable unecrypted localhost access for unbound-control"))
96 ctl.rmempty = false
97
98 dlk = s1:taboption("advanced", ListValue, "dhcp_link", translate("DHCP Link:"),
99   translate("Link to supported programs to load DHCP into DNS"))
100 dlk:value("none", translate("No Link"))
101 dlk:value("dnsmasq", "dnsmasq")
102 dlk:value("odhcpd", "odhcpd")
103 dlk.rmempty = false
104
105 dom = s1:taboption("advanced", Value, "domain", translate("Local Domain:"),
106   translate("Domain suffix for this router and DHCP clients"))
107 dom.placeholder = "lan"
108 dom:depends({ dhcp_link = "none" })
109 dom:depends({ dhcp_link = "odhcpd" })
110
111 dty = s1:taboption("advanced", ListValue, "domain_type", translate("Local Domain Type:"),
112   translate("How to treat queries of this local domain"))
113 dty:value("deny", translate("Ignored"))
114 dty:value("refuse", translate("Refused"))
115 dty:value("static", translate("Only Local"))
116 dty:value("transparent", translate("Also Forwarded"))
117 dty:depends({ dhcp_link = "none" })
118 dty:depends({ dhcp_link = "odhcpd" })
119
120 lfq = s1:taboption("advanced", ListValue, "add_local_fqdn", translate("LAN DNS:"),
121   translate("How to enter the LAN or local network router in DNS"))
122 lfq:value("0", translate("No DNS"))
123 lfq:value("1", translate("Hostname, Primary Address"))
124 lfq:value("2", translate("Hostname, All Addresses"))
125 lfq:value("3", translate("Host FQDN, All Addresses"))
126 lfq:value("4", translate("Interface FQDN, All Addresses"))
127 lfq:depends({ dhcp_link = "none" })
128 lfq:depends({ dhcp_link = "odhcpd" })
129
130 wfq = s1:taboption("advanced", ListValue, "add_wan_fqdn", translate("WAN DNS:"),
131   translate("Override the WAN side router entry in DNS"))
132 wfq:value("0", translate("Upstream"))
133 wfq:value("1", translate("Hostname, Primary Address"))
134 wfq:value("2", translate("Hostname, All Addresses"))
135 wfq:value("3", translate("Host FQDN, All Addresses"))
136 wfq:value("4", translate("Interface FQDN, All Addresses"))
137 wfq:depends({ dhcp_link = "none" })
138 wfq:depends({ dhcp_link = "odhcpd" })
139
140 exa = s1:taboption("advanced", ListValue, "add_extra_dns", translate("Extra DNS:"),
141   translate("Use extra DNS entries found in /etc/config/dhcp"))
142 exa:value("0", translate("Ignore"))
143 exa:value("1", translate("Include Network/Hostnames"))
144 exa:value("2", translate("Advanced MX/SRV RR"))
145 exa:value("3", translate("Advanced CNAME RR"))
146 exa:depends({ dhcp_link = "none" })
147 exa:depends({ dhcp_link = "odhcpd" })
148
149 ctl = s1:taboption("advanced", Flag, "dhcp4_slaac6", translate("DHCPv4 to SLAAC:"),
150   translate("Use DHCPv4 MAC to discover IP6 hosts SLAAC (EUI64)"))
151 ctl.rmempty = false
152
153 d64 = s1:taboption("advanced", Flag, "dns64", translate("Enable DNS64:"),
154   translate("Enable the DNS64 module"))
155 d64.rmempty = false
156
157 pfx = s1:taboption("advanced", Value, "dns64_prefix", translate("DNS64 Prefix:"),
158   translate("Prefix for generated DNS64 addresses"))
159 pfx.datatype = "ip6addr"
160 pfx.placeholder = "64:ff9b::/96"
161 pfx.optional = true
162 pfx:depends({ dns64 = true })
163
164 qry = s1:taboption("advanced", Flag, "query_minimize", translate("Query Minimize:"),
165   translate("Break down query components for limited added privacy"))
166 qry.rmempty = false
167
168 qrs = s1:taboption("advanced", Flag, "query_min_strict", translate("Strict Minimize:"),
169   translate("Strict version of 'query minimize' but it can break DNS"))
170 qrs.rmempty = false
171 qrs:depends({ query_minimize = true })
172
173 --TODO: dnsmasq needs to not reference resolve-file and get off port 53.
174
175 --Resource Tuning Tab
176
177 pro = s1:taboption("resource", ListValue, "protocol", translate("Recursion Protocol:"),
178   translate("Chose the protocol recursion queries leave on"))
179 pro:value("mixed", translate("IP4 and IP6"))
180 pro:value("ip6_prefer", translate("IP6 Preferred"))
181 pro:value("ip4_only", translate("IP4 Only"))
182 pro:value("ip6_only", translate("IP6 Only"))
183 pro.rmempty = false
184
185 rsn = s1:taboption("resource", ListValue, "recursion", translate("Recursion Strength:"),
186   translate("Recursion activity affects memory growth and CPU load"))
187 rsn:value("aggressive", translate("Aggressive"))
188 rsn:value("default", translate("Default"))
189 rsn:value("passive", translate("Passive"))
190 rsn.rmempty = false
191
192 rsc = s1:taboption("resource", ListValue, "resource", translate("Memory Resource:"),
193   translate("Use menu System/Processes to observe any memory growth"))
194 rsc:value("large", translate("Large"))
195 rsc:value("medium", translate("Medium"))
196 rsc:value("small", translate("Small"))
197 rsc:value("tiny", translate("Tiny"))
198 rsc.rmempty = false
199
200 ag2 = s1:taboption("resource", Value, "root_age", translate("Root DSKEY Age:"),
201   translate("Limit days between RFC5011 to reduce flash writes"))
202 ag2.datatype = "and(uinteger,min(1),max(99))"
203 ag2:value("3", "3")
204 ag2:value("9", "9 ("..translate("default")..")")
205 ag2:value("12", "12")
206 ag2:value("24", "24")
207 ag2:value("99", "99 ("..translate("never")..")")
208
209 tgr = s1:taboption("resource", Value, "trigger", translate("Trigger Networks:"),
210   translate("Networks that may trigger Unbound to reload (avoid wan6)"))
211 tgr.template = "cbi/network_netlist"
212 tgr.widget = "checkbox"
213 tgr.cast = "string"
214
215 return m
216