luci-app-statistics: add missing ValuesPercentage option
[project/luci.git] / applications / luci-app-unbound / luasrc / model / cbi / unbound / zone-details.lua
1 -- Copyright 2018 Eric Luehrsen <ericluehrsen@gmail.com>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local sy = require "luci.sys"
5 local ds = require "luci.dispatcher"
6 local hp = require "luci.http"
7 local m7, s7
8 local ena, flb, zty, znm, srv, rlv, tlu
9 local prt, tlp, tli, url
10
11 arg[1] = arg[1] or ""
12 m7 = Map("unbound")
13 m7.redirect = ds.build_url("admin/services/unbound/zones")
14
15
16 if (arg[1] == "") then
17 hp.redirect(m7.redirect)
18 return
19
20 else
21 s7 = m7:section(NamedSection, arg[1], "zone",
22 translatef("Directed Zone"),
23 translatef("Edit a forward, stub, or zone-file-cache zone "
24 .. "for Unbound to use instead of recursion."))
25
26 s7.anonymous = true
27 s7.addremove = false
28
29 ena = s7:option(Flag, "enabled", translate("Enabled"),
30 translate("Enable this directed zone"))
31 ena.rmempty = false
32
33 flb = s7:option(Flag, "fallback", translate("Fall Back"),
34 translate("Allow open recursion when record not in zone"))
35 flb.rmempty = false
36
37 zty = s7:option(ListValue, "zone_type", translate("Zone Type"))
38 zty:value("auth_zone", translate("Authoritative (zone file)"))
39 zty:value("stub_zone", translate("Stub (forced recursion)"))
40 zty:value("forward_zone", translate("Forward (simple handoff)"))
41 zty.rmempty = false
42
43 znm = s7:option(DynamicList, "zone_name", translate("Zone Names"),
44 translate("Zone (Domain) names included in this zone combination"))
45 znm.placeholder="new.example.net."
46
47 srv = s7:option(DynamicList, "server", translate("Servers"),
48 translate("Servers for this zone; see README.md for optional form"))
49 srv.placeholder="192.0.2.53"
50
51 rlv = s7:option(Flag, "resolv_conf", translate("Use 'resolv.conf.auto'"),
52 translate("Forward to upstream nameservers (ISP)"))
53 rlv:depends("zone_type", "forward_zone")
54
55 tlu = s7:option(Flag, "tls_upstream", translate("DNS over TLS"),
56 translate("Connect to servers using TLS"))
57 tlu:depends("zone_type", "forward_zone")
58
59 prt = s7:option(Value, "port", translate("Server Port"),
60 translate("Port servers will receive queries on"))
61 prt:depends("tls_upstream", false)
62 prt.datatype = "port"
63 prt.placeholder="53"
64
65 tlp = s7:option(Value, "tls_port", translate("Server TLS Port"),
66 translate("Port servers will receive queries on"))
67 tlp:depends("tls_upstream", true)
68 tlp.datatype = "port"
69 tlp.placeholder="853"
70
71 tli = s7:option(Value, "tls_index", translate("TLS Name Index"),
72 translate("Domain name to verify TLS certificate"))
73 tli:depends("tls_upstream", true)
74 tli.placeholder="dns.example.net"
75
76 url = s7:option(Value, "url_dir", translate("Zone Download URL"),
77 translate("Directory only part of URL"))
78 url:depends("zone_type", "auth_zone")
79 url.placeholder="https://www.example.net/dl/zones/"
80 end
81
82
83 function m7.on_commit(self)
84 if sy.init.enabled("unbound") then
85 -- Restart Unbound with configuration
86 sy.call("/etc/init.d/unbound restart >/dev/null 2>&1")
87
88 else
89 sy.call("/etc/init.d/unbound stop >/dev/null 2>&1")
90 end
91 end
92
93
94 return m7
95