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