luci-app-unbound: clean up presentation of advanced LuCI tabs

Add CSS for editing tabs to provide monospace font and offset
editing window color from read only windows. Expand 'control'
option to match with net/unbound. Add 'extended_stats' option
to match with net/unbound.

Signed-off-by: Eric Luehrsen <ericluehrsen@hotmail.com>
This commit is contained in:
Eric Luehrsen 2017-09-17 23:31:15 -04:00
parent 678c15c0da
commit 7ca169710e
7 changed files with 68 additions and 38 deletions

View file

@ -8,7 +8,7 @@ module("luci.controller.unbound", package.seeall)
function index() function index()
local ucl = luci.model.uci.cursor() local ucl = luci.model.uci.cursor()
local valexp = ucl:get_first("unbound", "unbound", "luci_expanded") local valexp = ucl:get_first("unbound", "unbound", "extended_luci")
local valman = ucl:get_first("unbound", "unbound", "manual_conf") local valman = ucl:get_first("unbound", "unbound", "manual_conf")
@ -89,7 +89,7 @@ end
function QueryStatistics() function QueryStatistics()
local lclhead = "Unbound Control Stats" local lclhead = "Unbound Control Stats"
local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf stats_noreset") local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf stats_noreset")
local lcldesc = luci.i18n.translate("This shows some performances statistics tracked by Unbound.") local lcldesc = luci.i18n.translate("This shows some performance statistics tracked by Unbound.")
luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata}) luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
end end
@ -97,7 +97,7 @@ end
function QueryLocalData() function QueryLocalData()
local lclhead = "Unbound Control Local Data" local lclhead = "Unbound Control Local Data"
local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf list_local_data") local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf list_local_data")
local lcldesc = luci.i18n.translate("This shows local RR including this router, DHCP assignments, and RFC1918 SOA stubs.") local lcldesc = luci.i18n.translate("This shows local host records that shortcut recursion.")
luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata}) luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
end end
@ -105,31 +105,47 @@ end
function QueryLocalZone() function QueryLocalZone()
local lclhead = "Unbound Control Local Zones" local lclhead = "Unbound Control Local Zones"
local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf list_local_zones") local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf list_local_zones")
local lcldesc = luci.i18n.translate("This shows local zones including LAN, adblock, forwarding, and RFC1918 in-arpa. ") local lcldesc = luci.i18n.translate("This shows local zone definitions that affect recursion routing or processing. ")
luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata}) luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
end end
function ShowUnboundConf() function ShowUnboundConf()
local unboundfile = "/var/lib/unbound/unbound.conf"
local lclhead = "Unbound Conf" local lclhead = "Unbound Conf"
local lcldata = luci.util.exec("cat /var/lib/unbound/unbound.conf") local lcldata = nixio.fs.readfile(unboundfile)
local lcldesc = luci.i18n.translate("This shows '/var/lib/unbound/unbound.conf' generated by UCI.") local lcldesc = luci.i18n.translate("This shows configuration generated by UCI:")
lcldesc = lcldesc .. " (" .. unboundfile .. ")"
luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata}) luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
end end
function ShowDHCPConf() function ShowDHCPConf()
local dhcpfile = "/var/lib/unbound/unbound_dhcp.conf"
local lclhead = "DHCP Conf" local lclhead = "DHCP Conf"
local lcldata = luci.util.exec("cat /var/lib/unbound/unbound_dhcp.conf") local lcldata = nixio.fs.readfile(dhcpfile)
local lcldesc = luci.i18n.translate("This shows '/var/lib/unbound/unbound_dhcp.conf' generated by DHCP hook script(s).") local lcldesc = luci.i18n.translate("This shows LAN hosts added by DHCP hook scripts:")
lcldesc = lcldesc .. " (" .. dhcpfile .. ")"
luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata}) luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
end end
function ShowAdblock() function ShowAdblock()
local adblockfile = "/var/lib/unbound/adb_list.overall"
local lclhead = "Adblock Conf" local lclhead = "Adblock Conf"
local lcldata = luci.util.exec("cat /var/lib/unbound/adb_list.overall") local lcldata, lcldesc
local lcldesc = luci.i18n.translate("This shows '/var/lib/unbound/adb_list.overall' provided by Adblock script(s).")
if nixio.fs.stat(adblockfile).size > 262144 then
lcldesc = luci.i18n.translate("Adblock domain list is too large for LuCI:")
lcldesc = lcldesc .. " (" .. adblockfile .. ")"
luci.template.render("unbound/show-empty", {heading = lclhead, description = lcldesc})
else
lcldata = nixio.fs.readfile(adblockfile)
lcldesc = luci.i18n.translate("This shows blocked domains provided by Adblock scripts:")
lcldesc = lcldesc .. " (" .. adblockfile .. ")"
luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata}) luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
end end
end

View file

@ -6,7 +6,7 @@
local m1, s1 local m1, s1
local ena, mcf, lci, lsv, rlh, rpv, vld, nvd, eds, prt, tlm local ena, mcf, lci, lsv, rlh, rpv, vld, nvd, eds, prt, tlm
local ctl, dlk, dom, dty, lfq, wfq, exa, dp6, d64, pfx, qry, qrs local ctl, dlk, dom, dty, lfq, wfq, exa, dp6, d64, pfx, qry, qrs
local pro, tgr, rsc, rsn, ag2 local pro, tgr, rsc, rsn, ag2, stt
local ucl = luci.model.uci.cursor() local ucl = luci.model.uci.cursor()
local valman = ucl:get_first("unbound", "unbound", "manual_conf") local valman = ucl:get_first("unbound", "unbound", "manual_conf")
@ -34,8 +34,8 @@ mcf = s1:taboption("basic", Flag, "manual_conf", translate("Manual Conf:"),
translate("Skip UCI and use /etc/unbound/unbound.conf")) translate("Skip UCI and use /etc/unbound/unbound.conf"))
mcf.rmempty = false mcf.rmempty = false
lci = s1:taboption("basic", Flag, "luci_expanded", translate("LuCI Expanded:"), lci = s1:taboption("basic", Flag, "extended_luci", translate("Advanced LuCI:"),
translate("See more detailed tabs for debug")) translate("See detailed tabs for debug and advanced manual configuration"))
lci.rmempty = false lci.rmempty = false
@ -109,9 +109,14 @@ if valman ~= "1" then
tlm.rmempty = false tlm.rmempty = false
--Advanced Tab --Advanced Tab
ctl = s1:taboption("advanced", Flag, "unbound_control", translate("Unbound Control App:"), ctl = s1:taboption("advanced", ListValue, "unbound_control", translate("Unbound Control App:"),
translate("Enable unecrypted localhost access for unbound-control")) translate("Enable access for unbound-control"))
ctl.rmempty = false ctl.rmempty = false
ctl:value("0", translate("No Remote Control"))
ctl:value("1", translate("Local Host, No Encryption"))
ctl:value("2", translate("Local Host, Encrypted"))
ctl:value("3", translate("Local Subnet, Encrypted"))
ctl:value("4", translate("Local Subnet, Static Encryption"))
dlk = s1:taboption("advanced", ListValue, "dhcp_link", translate("DHCP Link:"), dlk = s1:taboption("advanced", ListValue, "dhcp_link", translate("DHCP Link:"),
translate("Link to supported programs to load DHCP into DNS")) translate("Link to supported programs to load DHCP into DNS"))
@ -223,6 +228,10 @@ if valman ~= "1" then
ag2:value("24", "24") ag2:value("24", "24")
ag2:value("99", "99 ("..translate("never")..")") ag2:value("99", "99 ("..translate("never")..")")
stt = s1:taboption("resource", Flag, "extended_stats", translate("Extended Statistics:"),
translate("Extended statistics are printed from unbound-control"))
stt.rmempty = false
tgr = s1:taboption("resource", Value, "trigger", translate("Trigger Networks:"), tgr = s1:taboption("resource", Value, "trigger", translate("Trigger Networks:"),
translate("Networks that may trigger Unbound to reload (avoid wan6)")) translate("Networks that may trigger Unbound to reload (avoid wan6)"))
tgr.template = "cbi/network_netlist" tgr.template = "cbi/network_netlist"

View file

@ -1,17 +1,16 @@
-- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com> -- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
-- Licensed to the public under the Apache License 2.0. -- Licensed to the public under the Apache License 2.0.
local filename = "/etc/unbound/unbound_ext.conf"
local m4, s4, frm local m4, s4, frm
local filename = "/etc/unbound/unbound_ext.conf"
local description = translatef("Here you may edit 'forward:' and 'remote-control:' in an extended 'include:'")
description = description .. " (" .. filename .. ")"
m4 = SimpleForm("editing", nil) m4 = SimpleForm("editing", nil)
m4:append(Template("unbound/css-editing"))
m4.submit = translate("Save") m4.submit = translate("Save")
m4.reset = false m4.reset = false
s4 = m4:section(SimpleSection, "Unbound Extended Conf", description)
s4 = m4:section(SimpleSection, "Unbound Extended Conf",
translatef("This allows you to edit %s which is copied to"
.. " /var/ and 'include:' last for 'forward:' and other clauses", filename))
frm = s4:option(TextValue, "data") frm = s4:option(TextValue, "data")
frm.datatype = "string" frm.datatype = "string"
frm.rows = 20 frm.rows = 20
@ -23,7 +22,7 @@ end
function frm.write(self, section, data) function frm.write(self, section, data)
return nixio.fs.writefile(filename, data) return nixio.fs.writefile(filename, luci.util.trim(data:gsub("\r\n", "\n")))
end end

View file

@ -1,17 +1,16 @@
-- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com> -- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
-- Licensed to the public under the Apache License 2.0. -- Licensed to the public under the Apache License 2.0.
local filename = "/etc/unbound/unbound.conf"
local m2, s2, frm local m2, s2, frm
local filename = "/etc/unbound/unbound.conf"
local description = translatef("Here you may edit raw 'unbound.conf' when you don't use UCI:")
description = description .. " (" .. filename .. ")"
m2 = SimpleForm("editing", nil) m2 = SimpleForm("editing", nil)
m2:append(Template("unbound/css-editing"))
m2.submit = translate("Save") m2.submit = translate("Save")
m2.reset = false m2.reset = false
s2 = m2:section(SimpleSection, "Unbound Conf", description)
s2 = m2:section(SimpleSection, "Unbound Conf",
translatef("This allows you to edit raw %s which is copied to"
.. " /var/ for Unbound's base conf when you don't use UCI", filename))
frm = s2:option(TextValue, "data") frm = s2:option(TextValue, "data")
frm.datatype = "string" frm.datatype = "string"
frm.rows = 20 frm.rows = 20
@ -23,7 +22,7 @@ end
function frm.write(self, section, data) function frm.write(self, section, data)
return nixio.fs.writefile(filename, data) return nixio.fs.writefile(filename, luci.util.trim(data:gsub("\r\n", "\n")))
end end

View file

@ -1,17 +1,16 @@
-- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com> -- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
-- Licensed to the public under the Apache License 2.0. -- Licensed to the public under the Apache License 2.0.
local filename = "/etc/unbound/unbound_srv.conf"
local m3, s3, frm local m3, s3, frm
local filename = "/etc/unbound/unbound_srv.conf"
local description = translatef("Here you may edit the 'server:' clause in an internal 'include:'")
description = description .. " (" .. filename .. ")"
m3 = SimpleForm("editing", nil) m3 = SimpleForm("editing", nil)
m3:append(Template("unbound/css-editing"))
m3.submit = translate("Save") m3.submit = translate("Save")
m3.reset = false m3.reset = false
s3 = m3:section(SimpleSection, "Unbound Server Conf", description)
s3 = m3:section(SimpleSection, "Unbound Server Conf",
translatef("This allows you to edit %s which is copied to"
.. " /var/ and 'include:' within the 'server:' section.", filename))
frm = s3:option(TextValue, "data") frm = s3:option(TextValue, "data")
frm.datatype = "string" frm.datatype = "string"
frm.rows = 20 frm.rows = 20
@ -23,7 +22,7 @@ end
function frm.write(self, section, data) function frm.write(self, section, data)
return nixio.fs.writefile(filename, data) return nixio.fs.writefile(filename, luci.util.trim(data:gsub("\r\n", "\n")))
end end

View file

@ -0,0 +1,8 @@
<style type="text/css">
textarea
{
background-color: #fffff0;
font-family: monospace;
}
</style>

View file

@ -2,7 +2,7 @@
<h3><%=heading:pcdata()%></h3> <h3><%=heading:pcdata()%></h3>
<p><%=description:pcdata()%></p> <p><%=description:pcdata()%></p>
<div> <div>
<textarea style="width: 100%; height: 480px;" readonly="readonly" wrap="off" rows="<%=content:cmatch("\n")+2%>"><%=content:pcdata()%></textarea> <textarea style="width: 100%; height: 480px; font-family: monospace;" readonly="readonly" wrap="off" rows="<%=content:cmatch("\n")+2%>"><%=content:pcdata()%></textarea>
</div> </div>
<%+footer%> <%+footer%>