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