2
0

zone-details.lua 3.4 KB

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