22f020021ca1bfa6276e4dc5cbe7456ad5d8505a
[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 -- Licensed to the public under the Apache License 2.0.
4
5 m = Map("unbound", translate("Recursive DNS"),
6         translate("Unbound is a validating, recursive, and caching DNS resolver."))
7         
8 s = m:section(TypedSection, "unbound", translate("Unbound Settings"))
9 s.addremove = false
10 s.anonymous = true
11
12 s:tab("service", translate("Unbound Service"))
13 s:tab("resource", translate("Unbound Resources"))
14 s:tab("dnsmasq", translate("Dnsmasq Link"))
15
16 --Enable Unbound
17
18 e = s:taboption("service", Flag, "enabled", translate("Enable Unbound:"),
19   translate("Enable the initialization scripts for Unbound"))
20 e.rmempty = false
21
22 function e.cfgvalue(self, section)
23         return luci.sys.init.enabled("unbound") and self.enabled or self.disabled
24 end
25
26 function e.write(self, section, value)
27         if value == "1" then
28                 luci.sys.init.enable("unbound")
29                 luci.sys.call("/etc/init.d/unbound start >/dev/null")
30         else
31                 luci.sys.call("/etc/init.d/unbound stop >/dev/null")
32                 luci.sys.init.disable("unbound")
33         end
34
35         return Flag.write(self, section, value)
36 end
37
38 --Service Tab
39
40 mcf = s:taboption("service", Flag, "manual_conf", translate("Manual Conf:"),
41   translate("Skip UCI and use /etc/unbound/unbound.conf"))
42 mcf.rmempty = false
43
44 lsv = s:taboption("service", Flag, "localservice", translate("Local Service:"),
45   translate("Accept queries only from local subnets"))
46 lsv.rmempty = false
47
48 qry = s:taboption("service", Flag, "query_minimize", translate("Query Minimize:"),
49   translate("Break down query components for small added privacy"))
50 qry.rmempty = false
51
52 rlh = s:taboption("service", Flag, "rebind_localhost", translate("Block Localhost Rebind:"),
53   translate("Prevent upstream response of 127.0.0.0/8"))
54 rlh.rmempty = false
55
56 rpv = s:taboption("service", Flag, "rebind_protection", translate("Block Private Rebind:"),
57   translate("Prevent upstream response of RFC1918 ranges"))
58 rpv.rmempty = false
59
60 vld = s:taboption("service", Flag, "validator", translate("Enable DNSSEC:"),
61   translate("Enable the DNSSEC validator module"))
62 vld.rmempty = false
63
64 nvd = s:taboption("service", Flag, "validator_ntp", translate("DNSSEC NTP Fix:"),
65   translate("Break the loop where DNSSEC needs NTP and NTP needs DNS"))
66 nvd.rmempty = false
67
68 eds = s:taboption("service", Value, "edns_size", translate("EDNS Size:"),
69   translate("Limit extended DNS packet size"))
70 eds.datatype = "and(uinteger,min(512),max(4096))"
71 eds.rmempty = false
72
73 prt = s:taboption("service", Value, "listen_port", translate("Listening Port:"),
74   translate("Choose Unbounds listening port"))
75 prt.datatype = "port"
76 prt.rmempty = false
77
78 tlm = s:taboption("service", Value, "ttl_min", translate("TTL Minimum:"),
79   translate("Prevent excessively short cache periods"))
80 tlm.datatype = "and(uinteger,min(0),max(600))"
81 tlm.rmempty = false
82
83 --Resource Tuning Tab
84
85 rsn = s:taboption("resource", ListValue, "recursion", translate("Recursion Strength:"),
86   translate("Recursion activity affects memory growth and CPU load"))
87 rsn:value("aggressive", translate("Aggressive"))
88 rsn:value("default", translate("Default"))
89 rsn:value("passive", translate("Passive"))
90 rsn.rmempty = false
91
92 rsc = s:taboption("resource", ListValue, "resource", translate("Memory Resource:"),
93   translate("Use menu System/Processes to observe any memory growth"))
94 rsc:value("large", translate("Large"))
95 rsc:value("medium", translate("Medium"))
96 rsc:value("small", translate("Small"))
97 rsc:value("tiny", translate("Tiny"))
98 rsc.rmempty = false
99
100 age = s:taboption("resource", Value, "root_age", translate("Root DSKEY Age:"),
101   translate("Limit days between RFC5011 to reduce flash writes"))
102 age.datatype = "and(uinteger,min(1),max(99))"
103 age:value("14", "14")
104 age:value("28", "28 ("..translate("default")..")")
105 age:value("45", "45")
106 age:value("90", "90")
107 age:value("99", "99 ("..translate("never")..")")
108
109 --Dnsmasq Link Tab
110
111 dld = s:taboption("dnsmasq", Flag, "dnsmasq_link_dns", translate("Link dnsmasq:"),
112   translate("Forward queries to dnsmasq for local clients"))
113 dld.rmempty = false
114
115 dgn = s:taboption("dnsmasq", Flag, "dnsmsaq_gate_name", translate("Local Gateway Name:"),
116   translate("Also query dnsmasq for this hosts outbound gateway"))
117 dgn.rmempty = false
118
119 --TODO: Read only repective dnsmasq options and inform user of link requirements.
120 --TODO: dnsmasq needs to not reference resolve-file and get off port 53.
121
122 return m
123