1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
3 -- Copyright 2017 Eric Luehrsen <ericluehrsen@hotmail.com>
4 -- Licensed to the public under the Apache License 2.0.
6 module("luci.controller.unbound", package.seeall)
10 local ucl = luci.model.uci.cursor()
11 local valexp = ucl:get_first("unbound", "unbound", "luci_expanded")
12 local valman = ucl:get_first("unbound", "unbound", "manual_conf")
15 if not nixio.fs.access("/etc/config/unbound") then
22 entry({"admin", "services", "unbound"}, firstchild(), _("Recursive DNS")).dependent = false
25 entry({"admin", "services", "unbound", "configure"}, cbi("unbound/configure"), _("Settings"), 10)
28 entry({"admin", "services", "unbound", "status"}, firstchild(), _("Status"), 20)
29 entry({"admin", "services", "unbound", "status", "syslog"}, call("QuerySysLog"), _("Log"), 50).leaf = true
32 if nixio.fs.access("/usr/sbin/unbound-control") then
33 -- Require unbound-control to execute
34 entry({"admin", "services", "unbound", "status", "statistics"}, call("QueryStatistics"), _("Statistics"), 10).leaf = true
35 entry({"admin", "services", "unbound", "status", "localdata"}, call("QueryLocalData"), _("Local Data"), 20).leaf = true
36 entry({"admin", "services", "unbound", "status", "localzone"}, call("QueryLocalZone"), _("Local Zones"), 30).leaf = true
39 entry({"admin", "services", "unbound", "status", "statistics"}, call("ShowEmpty"), _("Statistics"), 10).leaf = true
44 entry({"admin", "services", "unbound", "files"}, firstchild(), _("Files"), 30)
48 entry({"admin", "services", "unbound", "files", "base"}, call("ShowUnboundConf"), _("UCI: Unbound"), 10).leaf = true
50 entry({"admin", "services", "unbound", "files", "base"}, cbi("unbound/manual"), _("Edit: Unbound"), 10).leaf = true
54 entry({"admin", "services", "unbound", "files", "server"}, cbi("unbound/server"), _("Edit: Server"), 20).leaf = true
55 entry({"admin", "services", "unbound", "files", "extended"}, cbi("unbound/extended"), _("Edit: Extended"), 30).leaf = true
58 if nixio.fs.access("/var/lib/unbound/unbound_dhcp.conf") then
59 entry({"admin", "services", "unbound", "files", "dhcp"}, call("ShowDHCPConf"), _("Include: DHCP"), 40).leaf = true
63 if nixio.fs.access("/var/lib/unbound/adb_list.overall") then
64 entry({"admin", "services", "unbound", "files", "adblock"}, call("ShowAdblock"), _("Include: Adblock"), 50).leaf = true
68 -- Simple View to UCI only
69 entry({"admin", "services", "unbound"}, cbi("unbound/configure"), _("Recursive DNS")).dependent = false
75 local lclhead = "Unbound Control"
76 local lcldesc = luci.i18n.translate("This could display more statistics with the unbound-control package.")
77 luci.template.render("unbound/show-empty", {heading = lclhead, description = lcldesc})
81 function QuerySysLog()
82 local lclhead = "System Log"
83 local lcldata = luci.util.exec("logread | grep -i unbound")
84 local lcldesc = luci.i18n.translate("This shows syslog filtered for events involving Unbound.")
85 luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
89 function QueryStatistics()
90 local lclhead = "Unbound Control Stats"
91 local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf stats_noreset")
92 local lcldesc = luci.i18n.translate("This shows some performances statistics tracked by Unbound.")
93 luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
97 function QueryLocalData()
98 local lclhead = "Unbound Control Local Data"
99 local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf list_local_data")
100 local lcldesc = luci.i18n.translate("This shows local RR including this router, DHCP assignments, and RFC1918 SOA stubs.")
101 luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
105 function QueryLocalZone()
106 local lclhead = "Unbound Control Local Zones"
107 local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf list_local_zones")
108 local lcldesc = luci.i18n.translate("This shows local zones including LAN, adblock, forwarding, and RFC1918 in-arpa. ")
109 luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
113 function ShowUnboundConf()
114 local lclhead = "Unbound Conf"
115 local lcldata = luci.util.exec("cat /var/lib/unbound/unbound.conf")
116 local lcldesc = luci.i18n.translate("This shows '/var/lib/unbound/unbound.conf' generated by UCI.")
117 luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
121 function ShowDHCPConf()
122 local lclhead = "DHCP Conf"
123 local lcldata = luci.util.exec("cat /var/lib/unbound/unbound_dhcp.conf")
124 local lcldesc = luci.i18n.translate("This shows '/var/lib/unbound/unbound_dhcp.conf' generated by DHCP hook script(s).")
125 luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
129 function ShowAdblock()
130 local lclhead = "Adblock Conf"
131 local lcldata = luci.util.exec("cat /var/lib/unbound/adb_list.overall")
132 local lcldesc = luci.i18n.translate("This shows '/var/lib/unbound/adb_list.overall' provided by Adblock script(s).")
133 luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})