summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--applications/luci-app-travelmate/luasrc/controller/travelmate.lua49
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua18
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua18
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua18
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua18
-rw-r--r--applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua58
-rw-r--r--applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm101
-rw-r--r--applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm45
-rw-r--r--applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm141
-rw-r--r--applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm200
-rw-r--r--applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm164
-rw-r--r--applications/luci-app-unbound/luasrc/controller/unbound.lua209
-rw-r--r--applications/luci-app-unbound/luasrc/model/cbi/unbound/configure.lua539
-rw-r--r--applications/luci-app-unbound/luasrc/model/cbi/unbound/extended.lua15
-rw-r--r--applications/luci-app-unbound/luasrc/model/cbi/unbound/manual.lua15
-rw-r--r--applications/luci-app-unbound/luasrc/model/cbi/unbound/server.lua15
-rw-r--r--applications/luci-app-unbound/luasrc/model/cbi/unbound/uciedit.lua37
-rw-r--r--applications/luci-app-unbound/luasrc/model/cbi/unbound/zones.lua207
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm101
-rw-r--r--themes/luci-theme-bootstrap/htdocs/luci-static/bootstrap/cascade.css5
-rw-r--r--themes/luci-theme-openwrt/htdocs/luci-static/openwrt.org/cascade.css15
21 files changed, 1259 insertions, 729 deletions
diff --git a/applications/luci-app-travelmate/luasrc/controller/travelmate.lua b/applications/luci-app-travelmate/luasrc/controller/travelmate.lua
index 493a387c3e..00969ffe7d 100644
--- a/applications/luci-app-travelmate/luasrc/controller/travelmate.lua
+++ b/applications/luci-app-travelmate/luasrc/controller/travelmate.lua
@@ -3,9 +3,12 @@
module("luci.controller.travelmate", package.seeall)
-local util = require("luci.util")
-local i18n = require("luci.i18n")
-local templ = require("luci.template")
+local sys = require("luci.sys")
+local util = require("luci.util")
+local http = require("luci.http")
+local i18n = require("luci.i18n")
+local json = require("luci.jsonc")
+local uci = require("luci.model.uci").cursor()
function index()
if not nixio.fs.access("/etc/config/travelmate") then
@@ -14,13 +17,16 @@ function index()
entry({"admin", "services", "travelmate"}, firstchild(), _("Travelmate"), 40).dependent = false
entry({"admin", "services", "travelmate", "tab_from_cbi"}, cbi("travelmate/overview_tab", {hideresetbtn=true, hidesavebtn=true}), _("Overview"), 10).leaf = true
entry({"admin", "services", "travelmate", "stations"}, template("travelmate/stations"), _("Wireless Stations"), 20).leaf = true
- entry({"admin", "services", "travelmate", "logfile"}, call("logread"), _("View Logfile"), 30).leaf = true
+ entry({"admin", "services", "travelmate", "log"}, template("travelmate/logread"), _("View Logfile"), 30).leaf = true
entry({"admin", "services", "travelmate", "advanced"}, firstchild(), _("Advanced"), 100)
entry({"admin", "services", "travelmate", "advanced", "configuration"}, form("travelmate/configuration_tab"), _("Edit Travelmate Configuration"), 110).leaf = true
entry({"admin", "services", "travelmate", "advanced", "cfg_wireless"}, form("travelmate/cfg_wireless_tab"), _("Edit Wireless Configuration"), 120).leaf = true
entry({"admin", "services", "travelmate", "advanced", "cfg_network"}, form("travelmate/cfg_network_tab"), _("Edit Network Configuration"), 130).leaf = true
entry({"admin", "services", "travelmate", "advanced", "cfg_firewall"}, form("travelmate/cfg_firewall_tab"), _("Edit Firewall Configuration"), 140).leaf = true
+ entry({"admin", "services", "travelmate", "logread"}, call("logread"), nil).leaf = true
+ entry({"admin", "services", "travelmate", "status"}, call("status_update"), nil).leaf = true
+ entry({"admin", "services", "travelmate", "action"}, call("trm_action"), nil).leaf = true
entry({"admin", "services", "travelmate", "apqr"}, template("travelmate/ap_qr")).leaf = true
entry({"admin", "services", "travelmate", "wifiscan"}, template("travelmate/wifi_scan")).leaf = true
entry({"admin", "services", "travelmate", "wifiadd"}, form("travelmate/wifi_add", {hideresetbtn=true, hidesavebtn=true})).leaf = true
@@ -29,13 +35,38 @@ function index()
entry({"admin", "services", "travelmate", "wifiorder"}, form("travelmate/wifi_order", {hideresetbtn=true, hidesavebtn=true})).leaf = true
end
+function trm_action(name)
+ if name == "do_restart" then
+ luci.sys.call("/etc/init.d/travelmate restart >/dev/null 2>&1")
+ end
+ luci.http.prepare_content("text/plain")
+ luci.http.write("0")
+end
+
+function status_update()
+ local rt_file
+ local content
+
+ rt_file = uci:get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json"
+
+ if nixio.fs.access(rt_file) then
+ content = json.parse(nixio.fs.readfile(rt_file) or "")
+ http.prepare_content("application/json")
+ http.write_json(content)
+ end
+end
+
function logread()
- local logfile = ""
+ local content
if nixio.fs.access("/var/log/messages") then
- logfile = util.trim(util.exec("grep -F 'travelmate-' /var/log/messages"))
- elseif nixio.fs.access("/sbin/logread") then
- logfile = util.trim(util.exec("logread -e 'travelmate-'"))
+ content = util.trim(util.exec("grep -F 'travelmate-' /var/log/messages"))
+ else
+ content = util.trim(util.exec("logread -e 'travelmate-'"))
+ end
+
+ if content == "" then
+ content = "No travelmate related logs yet!"
end
- templ.render("travelmate/logread", {title = i18n.translate("Travelmate Logfile"), content = logfile})
+ http.write(content)
end
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua
index e5a048fa88..fea190e9b9 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_firewall_tab.lua
@@ -1,11 +1,11 @@
--- Copyright 2017 Dirk Brenken (dev@brenken.org)
+-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
-- This is free software, licensed under the Apache License, Version 2.0
-local fs = require("nixio.fs")
-local util = require("luci.util")
-local trminput = "/etc/config/firewall"
+local fs = require("nixio.fs")
+local util = require("luci.util")
+local input = "/etc/config/firewall"
-if not nixio.fs.access(trminput) then
+if not fs.access(input) then
m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
return m
end
@@ -23,11 +23,15 @@ f.rows = 20
f.rmempty = true
function f.cfgvalue()
- return nixio.fs.readfile(trminput) or ""
+ return fs.readfile(input) or ""
end
function f.write(self, section, data)
- return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
+ return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
+end
+
+function f.remove(self, section, value)
+ return fs.writefile(input, "")
end
function s.handle(self, state, data)
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua
index 0096d6a8c2..6f0ade772d 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_network_tab.lua
@@ -1,11 +1,11 @@
--- Copyright 2017 Dirk Brenken (dev@brenken.org)
+-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
-- This is free software, licensed under the Apache License, Version 2.0
-local fs = require("nixio.fs")
-local util = require("luci.util")
-local trminput = "/etc/config/network"
+local fs = require("nixio.fs")
+local util = require("luci.util")
+local input = "/etc/config/network"
-if not nixio.fs.access(trminput) then
+if not fs.access(input) then
m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
return m
end
@@ -23,11 +23,15 @@ f.rows = 20
f.rmempty = true
function f.cfgvalue()
- return nixio.fs.readfile(trminput) or ""
+ return fs.readfile(input) or ""
end
function f.write(self, section, data)
- return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
+ return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
+end
+
+function f.remove(self, section, value)
+ return fs.writefile(input, "")
end
function s.handle(self, state, data)
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua
index 7ef9920a08..ab59dfb376 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/cfg_wireless_tab.lua
@@ -1,11 +1,11 @@
--- Copyright 2017 Dirk Brenken (dev@brenken.org)
+-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
-- This is free software, licensed under the Apache License, Version 2.0
-local fs = require("nixio.fs")
-local util = require("luci.util")
-local trminput = "/etc/config/wireless"
+local fs = require("nixio.fs")
+local util = require("luci.util")
+local input = "/etc/config/wireless"
-if not nixio.fs.access(trminput) then
+if not fs.access(input) then
m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
return m
end
@@ -23,11 +23,15 @@ f.rows = 20
f.rmempty = true
function f.cfgvalue()
- return nixio.fs.readfile(trminput) or ""
+ return fs.readfile(input) or ""
end
function f.write(self, section, data)
- return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
+ return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
+end
+
+function f.remove(self, section, value)
+ return fs.writefile(input, "")
end
function s.handle(self, state, data)
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua
index 8a20ab9cce..7bb32c1ec5 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/configuration_tab.lua
@@ -1,11 +1,11 @@
--- Copyright 2017 Dirk Brenken (dev@brenken.org)
+-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
-- This is free software, licensed under the Apache License, Version 2.0
-local fs = require("nixio.fs")
-local util = require("luci.util")
-local trminput = "/etc/config/travelmate"
+local fs = require("nixio.fs")
+local util = require("luci.util")
+local input = "/etc/config/travelmate"
-if not nixio.fs.access(trminput) then
+if not fs.access(input) then
m = SimpleForm("error", nil, translate("Input file not found, please check your configuration."))
m.reset = false
m.submit = false
@@ -25,11 +25,15 @@ f.rows = 20
f.rmempty = true
function f.cfgvalue()
- return nixio.fs.readfile(trminput) or ""
+ return fs.readfile(input) or ""
end
function f.write(self, section, data)
- return nixio.fs.writefile(trminput, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
+ return fs.writefile(input, "\n" .. util.trim(data:gsub("\r\n", "\n")) .. "\n")
+end
+
+function f.remove(self, section, value)
+ return fs.writefile(input, "")
end
function s.handle(self, state, data)
diff --git a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua
index a1dcbc638c..ab39dab6bd 100644
--- a/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua
+++ b/applications/luci-app-travelmate/luasrc/model/cbi/travelmate/overview_tab.lua
@@ -3,15 +3,12 @@
local fs = require("nixio.fs")
local uci = require("luci.model.uci").cursor()
-local json = require("luci.jsonc")
local util = require("luci.util")
local nw = require("luci.model.network").init()
local fw = require("luci.model.firewall").init()
local dump = util.ubus("network.interface", "dump", {})
local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan"
-local trminput = uci:get("travelmate", "global", "trm_rtfile") or "/tmp/trm_runtime.json"
local uplink = uci:get("network", trmiface) or ""
-local parse = json.parse(fs.readfile(trminput) or "")
m = Map("travelmate", translate("Travelmate"),
translate("Configuration of the travelmate package to to enable travel router functionality. ")
@@ -20,11 +17,9 @@ m = Map("travelmate", translate("Travelmate"),
.. "see online documentation</a>", "https://github.com/openwrt/packages/blob/master/net/travelmate/files/README.md"))
m:chain("network")
m:chain("firewall")
-m.apply_on_parse = true
function m.on_apply(self)
luci.sys.call("env -i /etc/init.d/travelmate restart >/dev/null 2>&1")
- luci.http.redirect(luci.dispatcher.build_url("admin", "services", "travelmate"))
end
-- Interface Wizard
@@ -33,7 +28,7 @@ if uplink == "" then
ds = m:section(NamedSection, "global", "travelmate", translate("Interface Wizard"))
o = ds:option(Value, "trm_iface", translate("Create Uplink interface"),
translate("Create a new wireless wan uplink interface, configure it to use dhcp and ")
- .. translate("add it to the wan zone of the firewall.<br />")
+ .. translate("add it to the wan zone of the firewall. ")
.. translate("This step has only to be done once."))
o.datatype = "and(uciname,rangelength(3,15))"
o.default = trmiface
@@ -96,55 +91,8 @@ end
-- Runtime information
-ds = m:section(NamedSection, "global", "travelmate", translate("Runtime Information"))
-
-dv1 = ds:option(DummyValue, "status", translate("Travelmate Status (Quality)"))
-dv1.template = "travelmate/runtime"
-if parse ~= nil then
- dv1.value = parse.data.travelmate_status or translate("n/a")
-else
- dv1.value = translate("n/a")
-end
-
-dv2 = ds:option(DummyValue, "travelmate_version", translate("Travelmate Version"))
-dv2.template = "travelmate/runtime"
-if parse ~= nil then
- dv2.value = parse.data.travelmate_version or translate("n/a")
-else
- dv2.value = translate("n/a")
-end
-
-dv3 = ds:option(DummyValue, "station_id", translate("Station ID (SSID/BSSID)"))
-dv3.template = "travelmate/runtime"
-if parse ~= nil then
- dv3.value = parse.data.station_id or translate("n/a")
-else
- dv3.value = translate("n/a")
-end
-
-dv4 = ds:option(DummyValue, "station_interface", translate("Station Interface"))
-dv4.template = "travelmate/runtime"
-if parse ~= nil then
- dv4.value = parse.data.station_interface or translate("n/a")
-else
- dv4.value = translate("n/a")
-end
-
-dv5 = ds:option(DummyValue, "station_radio", translate("Station Radio"))
-dv5.template = "travelmate/runtime"
-if parse ~= nil then
- dv5.value = parse.data.station_radio or translate("n/a")
-else
- dv5.value = translate("n/a")
-end
-
-dv6 = ds:option(DummyValue, "last_rundate", translate("Last rundate"))
-dv6.template = "travelmate/runtime"
-if parse ~= nil then
- dv6.value = parse.data.last_rundate or translate("n/a")
-else
- dv6.value = translate("n/a")
-end
+ds = s:option(DummyValue, "_dummy")
+ds.template = "travelmate/runtime"
-- Extra options
diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm
index a92dbe1469..3f01a81e35 100644
--- a/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm
+++ b/applications/luci-app-travelmate/luasrc/view/travelmate/ap_qr.htm
@@ -6,60 +6,61 @@ This is free software, licensed under the Apache License, Version 2.0
<%+header%>
<div class="cbi-map">
- <div class="cbi-map-descr">
- <%=translate("Here you'll find the QR codes from all of your configured Access Points. It allows you to connect your Android or iOS devices to your router's WiFi using the QR code shown below.")%>
- </div>
-<%-
- local write = io.write
- local uci = require("luci.model.uci").cursor()
+ <div class="cbi-map-descr">
+ <%=translate("Here you'll find the QR codes from all of your configured Access Points. It allows you to connect your Android or iOS devices to your router's WiFi using the QR code shown below.")%>
+ </div>
+ <%- local uci = require("luci.model.uci").cursor()
- uci:foreach("wireless", "wifi-iface", function(s)
- local device = s.device or ""
- local mode = s.mode or ""
- local ssid = s.ssid or ""
- local enc = s.encryption or ""
- local key = s.key or ""
- local hidden = s.hidden or "false"
- local disabled = s.disabled or ""
- local wep_slots = {s.key1 or "", s.key2 or "", s.key3 or "", s.key4 or ""}
+ uci:foreach("wireless", "wifi-iface", function(s)
+ local device = s.device or ""
+ local mode = s.mode or ""
+ local ssid = s.ssid or ""
+ local enc = s.encryption or ""
+ local key = s.key or ""
+ local hidden = s.hidden or "false"
+ local disabled = s.disabled or ""
+ local wep_slots = {s.key1 or "", s.key2 or "", s.key3 or "", s.key4 or ""}
- if device and mode == "ap" and disabled ~= "1" then
- if string.match(enc, '^psk') then
- enc = "WPA"
- elseif string.match(enc, '^wep') then
- enc = "WEP"
- if tonumber(key) then
- key = wep_slots[tonumber(key)]
- end
- elseif enc == "none" then
- enc = "nopass"
- key = "nokey"
- else
- enc = ""
- end
- if hidden == "1" then
- hidden = "true"
- end
- if ssid and enc and key then
- local e_ssid = string.gsub(ssid,"[\"\\';:, ]",[[\\\%1]])
- local e_key = string.gsub(key,"[\"\\';:, ]",[[\\\%1]])
- local qrcode = ""
- qrcode = luci.sys.exec("/usr/bin/qrencode --inline --8bit --type=SVG --output=- 'WIFI:S:\"'" .. e_ssid .. "'\";T:'" .. enc .. "';P:\"'" .. e_key .. "'\";H:'" .. hidden .. "';'")
--%>
- <fieldset class="cbi-section">
- <legend>AP on <%=device%> with SSID "<%=ssid%>"</legend>
- <h3 name="content"><%=qrcode%></h3>
- </fieldset>
-<%-
- end
- end
- end)
-%>
+ if device and mode == "ap" and disabled ~= "1" then
+ if string.match(enc, '^psk') then
+ enc = "WPA"
+ elseif string.match(enc, '^wep') then
+ enc = "WEP"
+ if tonumber(key) then
+ key = wep_slots[tonumber(key)]
+ end
+ elseif enc == "none" then
+ enc = "nopass"
+ key = "nokey"
+ else
+ enc = ""
+ end
+
+ if hidden == "1" then
+ hidden = "true"
+ end
+
+ if ssid and enc and key then
+ local e_ssid = string.gsub(ssid,"[\"\\';:, ]",[[\\\%1]])
+ local e_key = string.gsub(key,"[\"\\';:, ]",[[\\\%1]])
+ local qrcode = ""
+
+ qrcode = luci.sys.exec("/usr/bin/qrencode --inline --8bit --type=SVG --output=- 'WIFI:S:\"'" .. e_ssid .. "'\";T:'" .. enc .. "';P:\"'" .. e_key .. "'\";H:'" .. hidden .. "';'")
+ -%>
+ <div class="cbi-section">
+ <h3>AP on <%=device%> with SSID "<%=ssid%>"</h3>
+ <h3><%=qrcode%></h3>
+ </div>
+ <%-
+ end
+ end
+ end)
+ -%>
</div>
<div class="cbi-page-actions right">
- <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/tab_from_cbi')%>" method="post">
- <input class="cbi-button cbi-button-reset" type="submit" value="<%:Back to overview%>"/>
- </form>
+ <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/tab_from_cbi')%>" method="post">
+ <input class="cbi-button cbi-button-reset" type="submit" value="<%:Back to overview%>" />
+ </form>
</div>
<%+footer%>
diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm
index c40bdeeb59..4457296f54 100644
--- a/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm
+++ b/applications/luci-app-travelmate/luasrc/view/travelmate/logread.htm
@@ -5,16 +5,47 @@ This is free software, licensed under the Apache License, Version 2.0
<%+header%>
+<style type="text/css">
+ select[readonly],
+ textarea[readonly]
+ {
+ width: 100%;
+ height: 450px;
+ border: 1px solid #cccccc;
+ padding: 5px;
+ font-size: 12px;
+ font-family: monospace;
+ resize: none;
+ pointer-events: auto;
+ cursor: auto;
+ }
+</style>
+
+<script type="text/javascript">
+//<![CDATA[
+ function log_update()
+ {
+ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "travelmate", "logread")%>', null,
+ function(x)
+ {
+ if (!x)
+ {
+ return;
+ }
+ var view = document.getElementById("view_id");
+ view.value = x.responseText;
+ view.scrollTop = view.scrollHeight;
+ });
+ }
+ window.onload = log_update();
+//]]>
+</script>
+
<div class="cbi-map">
<div class="cbi-section">
- <div class="cbi-section-descr"><%:This form shows the syslog output, pre-filtered for travelmate related messages only.%></div>
- <textarea id="logread_id" style="width: 100%; height: 450px; border: 1px solid #cccccc; padding: 5px; font-size: 12px; font-family: monospace; resize: none;" readonly="readonly" wrap="off" rows="<%=content:cmatch("\n")+2%>"><%=content:pcdata()%></textarea>
+ <div class="cbi-section-descr"><%:The syslog output, pre-filtered for travelmate related messages only.%></div>
+ <textarea id="view_id" readonly="readonly" wrap="off" value=""></textarea>
</div>
</div>
-<script type="text/javascript">
- var textarea = document.getElementById('logread_id');
- textarea.scrollTop = textarea.scrollHeight;
-</script>
-
<%+footer%>
diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm
index 7e93efab91..aba4a32018 100644
--- a/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm
+++ b/applications/luci-app-travelmate/luasrc/view/travelmate/runtime.htm
@@ -3,8 +3,143 @@ Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
This is free software, licensed under the Apache License, Version 2.0
-%>
-<%+cbi/valueheader%>
+<style type="text/css">
+ .runtime
+ {
+ color: #37c;
+ //#0069d6;
+ font-weight: bold;
+ display: inline-block;
+ width: 100%;
+ padding-top: 0.5rem;
+ }
+</style>
-<input name="runtime" id="runtime" type="text" class="cbi-input-text" style="outline:none;border:none;box-shadow:none;background:transparent;color:#0069d6;font-weight:bold;line-height:30px;height:30px;width:50em;" value="<%=self:cfgvalue(section)%>" disabled="disabled" />
+<script type="text/javascript">
+//<![CDATA[
+ function status_update(json)
+ {
+ var btn1 = document.getElementById("btn1");
+ var view = document.getElementById("value_1");
+ var input = json.data.travelmate_status;
+
+ btn1.value = "<%:Restart%>";
+ btn1.name = "do_restart";
+ view.innerHTML = input || "-";
+ view = document.getElementById("value_2");
+ input = json.data.travelmate_version;
+ view.innerHTML = input || "-";
+ view = document.getElementById("value_3");
+ input = json.data.station_id;
+ view.innerHTML = input || "-";
+ view = document.getElementById("value_4");
+ input = json.data.station_interface;
+ view.innerHTML = input || "-";
+ view = document.getElementById("value_5");
+ input = json.data.faulty_stations;
+ view.innerHTML = input || "-";
+ view = document.getElementById("value_6");
+ input = json.data.last_rundate;
+ view.innerHTML = input || "-";
+ btn1.disabled = false;
+ running(btn1_running, 0);
+ }
-<%+cbi/valuefooter%>
+ function btn_action(action)
+ {
+ var btn1 = document.getElementById("btn1");
+ var btn1_running = document.getElementById("btn1_running");
+
+ btn1.disabled = true;
+ running(btn1_running, 1);
+
+ new XHR.get('<%=luci.dispatcher.build_url("admin", "services", "travelmate")%>/action/' + action.name, null,
+ function(x)
+ {
+ if (!x)
+ {
+ return;
+ }
+ });
+ }
+
+ function running(element, state)
+ {
+ if (state === 1)
+ {
+ var running_html = '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" width="16" height="16" style="vertical-align:middle" />';
+ element.innerHTML = running_html;
+ }
+ else
+ {
+ element.innerHTML = '';
+ }
+ }
+
+ XHR.get('<%=luci.dispatcher.build_url("admin", "services", "travelmate", "status")%>', null,
+ function(x, json_info)
+ {
+ if (!x || !json_info)
+ {
+ return;
+ }
+ status_update(json_info)
+ });
+
+ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "travelmate", "status")%>', null,
+ function(x, json_info)
+ {
+ if (!x || !json_info)
+ {
+ return;
+ }
+ status_update(json_info)
+ });
+//]]>
+</script>
+
+<h3><%:Runtime Information%></h3>
+<div class="cbi-value" id="status_1">
+ <label class="cbi-value-title" for="status_1"><%:Travelmate Status (Quality)%></label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_1">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_2">
+ <label class="cbi-value-title" for="status_2"><%:Travelmate Version%></label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_2">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_3">
+ <label class="cbi-value-title" for="status_3"><%:Station ID (RADIO/SSID/BSSID)%></label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_3">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_4">
+ <label class="cbi-value-title" for="status_4"><%:Station Interface%></label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_4">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_5">
+ <label class="cbi-value-title" for="status_5"><%:Faulty Stations%></label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_5">-</span>
+ </div>
+</div>
+<div class="cbi-value" id="status_6">
+ <label class="cbi-value-title" for="status_6"><%:Last Run%></label>
+ <div class="cbi-value-field">
+ <span class="runtime" id="value_6">-</span>
+ </div>
+</div>
+<hr />
+<div class="cbi-value" id="button_1">
+ <label class="cbi-value-title" for="button_1"><%:Restart Travelmate%></label>
+ <div class="cbi-value-field">
+ <input class="cbi-button cbi-button-reset" id="btn1" type="button" value="" onclick="btn_action(this)" />
+ <span id="btn1_running" style="display:inline-block; width:16px; height:16px; margin:0 5px"></span>
+ </div>
+</div>
diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm
index 74542a9ca5..98e2e64bce 100644
--- a/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm
+++ b/applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm
@@ -4,75 +4,151 @@ This is free software, licensed under the Apache License, Version 2.0
-%>
<%-
- local write = io.write
- local uci = require("luci.model.uci").cursor()
- local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan"
+ local uci = require("luci.model.uci").cursor()
+ local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan"
-%>
<%+header%>
+<script type="text/javascript">
+//<![CDATA[
+ function status_update(json)
+ {
+ var i;
+ var j;
+ var search;
+ var view;
+ var list;
+ var status = json.data.travelmate_status;
+ var faulty = json.data.faulty_stations;
+
+ if (faulty)
+ {
+ var faulty_array = faulty.split(' ');
+ for (i = 0; i < faulty_array.length; i++)
+ {
+ for (j = 1; j <= 5; j++)
+ {
+ search = j + "_" + faulty_array[i];
+ view = document.getElementById(search);
+ if (view)
+ {
+ view.setAttribute("name", "station_nok");
+ view.setAttribute("style", "color: #a22; font-weight: bold");
+ }
+ }
+ }
+ }
+ else
+ {
+ list = document.getElementsByName("station_nok");
+ if (list.length > 0)
+ {
+ for (i = 0; i < list.length; i++)
+ {
+ list[i].removeAttribute("style");
+ }
+ }
+ }
+
+ if (status.startsWith("connected"))
+ {
+ for (i = 1; i <= 5; i++)
+ {
+ search = i + "_" + json.data.station_id;
+ view = document.getElementById(search);
+ if (view)
+ {
+ view.setAttribute("style", "color: #37c; font-weight: bold");
+ }
+ }
+ }
+ else
+ {
+ list = document.getElementsByName("station_ok");
+ if (list.length > 0)
+ {
+ for (i = 0; i < list.length; i++)
+ {
+ list[i].removeAttribute("style");
+ }
+ }
+ }
+ }
+
+ XHR.get('<%=luci.dispatcher.build_url("admin", "services", "travelmate", "status")%>', null,
+ function(x, json_info)
+ {
+ if (!x || !json_info)
+ {
+ return;
+ }
+ status_update(json_info)
+ });
+
+ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "travelmate", "status")%>', null,
+ function(x, json_info)
+ {
+ if (!x || !json_info)
+ {
+ return;
+ }
+ status_update(json_info)
+ });
+//]]>
+</script>
<div class="cbi-map">
-<div class="cbi-map-descr">
- <%=translatef("Provides an overview of all configured uplinks for the travelmate interface (%s). You can edit, delete or re-order existing uplinks or scan for a new one. The currently used uplink is emphasized in blue.", trmiface)%>
-</div>
+ <div class="cbi-map-descr">
+ <%=translatef("Provides an overview of all configured uplinks for the travelmate interface (%s). You can edit, delete or re-order existing uplinks or scan for a new one. The currently used uplink is emphasized in blue, faulty stations in red.", trmiface)%>
+ </div>
-<div class="cbi-section">
- <div class="table cbi-section-table">
- <div class="tr cbi-section-table-titles">
- <div class="th left"><%:Device%></div>
- <div class="th left"><%:SSID%></div>
- <div class="th left"><%:BSSID%></div>
- <div class="th left"><%:Encryption%></div>
- <div class="th center">&#160;</div>
- </div>
-<%
- uci:foreach("wireless", "wifi-iface", function(s)
- local iface = s.network or ""
- if iface == trmiface then
- local section = s['.name'] or ""
- local device = s.device or "-"
- local ssid = s.ssid or "-"
- local bssid = s.bssid or "-"
- local encryption = s.encryption or "-"
- local disabled = s.disabled or ""
- local style = "text-align:left;color:#000000"
- if disabled == "0" then
- style = "text-align:left;color:#0069d6;font-weight:bold"
- end
-%>
- <div class="tr cbi-section-table-row cbi-rowstyle-1" style="<%=style%>">
- <div class="td" style="<%=style%>"><%=device%></div>
- <div class="td" style="<%=style%>"><%=ssid%></div>
- <div class="td" style="<%=style%>"><%=bssid%></div>
- <div class="td" style="<%=style%>"><%=encryption%></div>
- <div class="td cbi-section-actions">
- <input class="cbi-button cbi-button-up" type="button" value="<%:Up%>" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>&amp;dir=up'" alt="<%:Move up%>" title="<%:Move up%>"/>
- <input class="cbi-button cbi-button-down" type="button" value="<%:Down%>" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>&amp;dir=down'" alt="<%:Move down%>" title="<%:Move down%>"/>
- <input type="button" class="cbi-button cbi-button-edit" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiedit')%>?cfg=<%=section%>'" title="<%:Edit this Uplink%>" value="<%:Edit%>"/>
- <input type="button" class="cbi-button cbi-button-remove" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifidelete')%>?cfg=<%=section%>'" title="<%:Delete this Uplink%>" value="<%:Delete%>"/>
- </div>
- </div>
-<%
- end
- end)
-%>
- </div>
-</div>
-<div class="cbi-page-actions right">
-<%
- uci:foreach("wireless", "wifi-device", function(s)
- local device = s[".name"]
-%>
- <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/wifiscan')%>" method="post">
- <input type="hidden" name="device" value="<%=device%>"/>
- <input type="hidden" name="token" value="<%=token%>"/>
- <input type="submit" class="cbi-button cbi-button-action important" title="<%:Find and join network on%> <%=device%>" value="<%:Scan%> <%=device%>"/>
- </form>
-<%
- end)
-%>
-</div>
+ <div class="cbi-section">
+ <div class="table cbi-section-table">
+ <div class="tr cbi-section-table-titles">
+ <div class="th left"><%:Device%></div>
+ <div class="th left"><%:SSID%></div>
+ <div class="th left"><%:BSSID%></div>
+ <div class="th left"><%:Encryption%></div>
+ <div class="th center"><%:Action%></div>
+ </div>
+ <%- uci:foreach("wireless", "wifi-iface", function(s)
+ local iface = s.network or ""
+ if iface == trmiface then
+ local section = s['.name'] or ""
+ local device = s.device or "-"
+ local ssid = s.ssid or "-"
+ local bssid = s.bssid or "-"
+ local encr = s.encryption or "-"
+ -%>
+ <div class="tr cbi-section-table-row cbi-rowstyle-1" name="station_ok" id="1_<%=device%>/<%=ssid%>/<%=bssid%>">
+ <div class="td left" name="station_ok" id="2_<%=device%>/<%=ssid%>/<%=bssid%>"><%=device%></div>
+ <div class="td left" name="station_ok" id="3_<%=device%>/<%=ssid%>/<%=bssid%>"><%=ssid%></div>
+ <div class="td left" name="station_ok" id="4_<%=device%>/<%=ssid%>/<%=bssid%>"><%=bssid%></div>
+ <div class="td left" name="station_ok" id="5_<%=device%>/<%=ssid%>/<%=bssid%>"><%=encr%></div>
+ <div class="td middle cbi-section-actions">
+ <div>
+ <input class="cbi-button cbi-button-up" type="button" value="<%:Up%>" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>&amp;dir=up'" alt="<%:Move up%>" title="<%:Move up%>" />
+ <input class="cbi-button cbi-button-down" type="button" value="<%:Down%>" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>&amp;dir=down'" alt="<%:Move down%>" title="<%:Move down%>" />
+ <input class="cbi-button cbi-button-edit" type="button" value="<%:Edit%>" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiedit')%>?cfg=<%=section%>'" title="<%:Edit this Uplink%>" />
+ <input class="cbi-button cbi-button-remove" type="button" value="<%:Delete%>" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifidelete')%>?cfg=<%=section%>'" title="<%:Delete this Uplink%>" />
+ </div>
+ </div>
+ </div>
+ <%- end; end) -%>
+ </div>
+ </div>
+ <div class="cbi-page-actions right">
+ <%- uci:foreach("wireless", "wifi-device", function(s)
+ local device = s[".name"]
+ local hwmode = s.hwmode or "-" -%>
+ <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/wifiscan')%>" method="post">
+ <input type="hidden" name="device" value="<%=device%>" />
+ <input type="hidden" name="token" value="<%=token%>" />
+ <input type="submit" class="cbi-button cbi-button-action important" title="<%:Find and join network on%> <%=device%>" value="<%:Scan%> <%=device%> (<%=hwmode%>)" />
+ </form>
+ <%- end) -%>
+ </div>
</div>
<%+footer%>
diff --git a/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm b/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm
index 8a417d69c2..ab3fe77fbc 100644
--- a/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm
+++ b/applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm
@@ -1,97 +1,99 @@
<%#
-Copyright 2017 Dirk Brenken (dev@brenken.org)
+Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
This is free software, licensed under the Apache License, Version 2.0
-%>
<%-
- local sys = require("luci.sys")
- local utl = require("luci.util")
- local dev = luci.http.formvalue("device")
- local iw = luci.sys.wifi.getiwinfo(dev)
- local wpa_label = {translate("WPA"), translate("WPA2"), translate("WPA/WPA2")}
+ local sys = require("luci.sys")
+ local utl = require("luci.util")
+ local dev = luci.http.formvalue("device")
+ local iw = luci.sys.wifi.getiwinfo(dev)
+ local label = {translate("WPA"), translate("WPA2"), translate("WPA/WPA2")}
- if not iw then
- luci.http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
- end
+ if not iw then
+ luci.http.redirect(luci.dispatcher.build_url("admin/services/travelmate/stations"))
+ end
- function format_wifi_encryption(info)
- if info.wep == true then
- return translate("WEP")
- elseif info.wpa > 0 then
- return "%s (%s/%s)" %{wpa_label[info.wpa], table.concat(info.auth_suites), table.concat(info.group_ciphers)}
- elseif info.enabled then
- return translate("Unknown")
- else
- return translate("Open")
- end
- end
+ function format_wifi_encryption(info)
+ if info.wep == true then
+ return translate("WEP")
+ elseif info.wpa > 0 then
+ return "%s (%s/%s)" %{label[info.wpa], table.concat(info.auth_suites), table.concat(info.group_ciphers)}
+ elseif info.enabled then
+ return translate("Unknown")
+ else
+ return translate("Open")
+ end
+ end
- function percent_wifi_signal(info)
- local qc = info.quality or 0
- local qm = info.quality_max or 0
- if info.bssid and qc > 0 and qm > 0 then
- return math.floor((100 / qm) * qc)
- else
- return 0
- end
- end
+ function percent_wifi_signal(info)
+ local qc = info.quality or 0
+ local qm = info.quality_max or 0
+ if info.bssid and qc > 0 and qm > 0 then
+ return math.floor((100 / qm) * qc)
+ else
+ return 0
+ end
+ end
-%>
<%+header%>
-
<div class="cbi-map">
-<h2 name="content"><%:Wireless Scan%></h2>
- <div class="cbi-section">
- <div class="table cbi-section-table">
- <div class="tr cbi-section-table-titles">
- <div class="th left"><%:Uplink SSID%></div>
- <div class="th left"><%:Uplink BSSID%></div>
- <div class="th left"><%:Encryption%></div>
- <div class="th left"><%:Signal strength%></div>
- </div>
- <% for i, net in ipairs(iw.scanlist or { }) do %>
- <div class="tr cbi-section-table-row cbi-rowstyle-1">
- <div class="td left">
- <%=net.ssid and utl.pcdata(net.ssid) or "<em>%s</em>" % translate("hidden")%>
- </div>
- <div class="td left">
- <%=net.bssid and utl.pcdata(net.bssid)%>
- </div>
- <div class="td left">
- <%=format_wifi_encryption(net.encryption)%>
- </div>
- <div class="td left">
- <%=percent_wifi_signal(net)%> %
- </div>
- <div class="td cbi-section-actions">
- <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/wifiadd')%>" method="post">
- <input type="hidden" name="token" value="<%=token%>"/>
- <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>"/>
- <input type="hidden" name="ssid" value="<%=utl.pcdata(net.ssid)%>"/>
- <input type="hidden" name="bssid" value="<%=utl.pcdata(net.bssid)%>"/>
- <input type="hidden" name="wep" value="<%=net.encryption.wep and 1 or 0%>"/>
- <% if net.encryption.wpa then %>
- <input type="hidden" name="wpa_version" value="<%=net.encryption.wpa%>"/>
- <% for _, v in ipairs(net.encryption.auth_suites) do %><input type="hidden" name="wpa_suites" value="<%=v%>"/><% end %>
- <% end %>
- <input class="cbi-button cbi-button-apply" type="submit" value="<%:Add Uplink%>"/>
- </form>
- </div>
- </div>
- <% end %>
- </div>
- </div>
-<div class="cbi-page-actions right">
- <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/stations')%>" method="get">
- <input class="cbi-button cbi-button-reset" type="submit" value="<%:Back to overview%>"/>
- </form>
- <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/wifiscan')%>" method="post">
- <input type="hidden" name="token" value="<%=token%>"/>
- <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>"/>
- <input class="cbi-button cbi-input-find" type="submit" value="<%:Repeat scan%>"/>
- </form>
-</div>
+ <h3><%:Wireless Scan%></h3>
+ <div class="cbi-section">
+ <div class="table cbi-section-table">
+ <div class="tr cbi-section-table-titles">
+ <div class="th left"><%:Uplink SSID%></div>
+ <div class="th left"><%:Uplink BSSID%></div>
+ <div class="th left"><%:Encryption%></div>
+ <div class="th left"><%:Signal strength%></div>
+ <div class="th center"><%:Action%></div>
+ </div>
+ <%- for i, net in ipairs(iw.scanlist or { }) do -%>
+ <div class="tr cbi-section-table-row cbi-rowstyle-1">
+ <div class="td left">
+ <%=net.ssid and utl.pcdata(net.ssid) or "<em>%s</em>" % translate("hidden")%>
+ </div>
+ <div class="td left">
+ <%=net.bssid and utl.pcdata(net.bssid)%>
+ </div>
+ <div class="td left">
+ <%=format_wifi_encryption(net.encryption)%>
+ </div>
+ <div class="td left">
+ <%=percent_wifi_signal(net)%> %
+ </div>
+ <div class="td cbi-section-actions">
+ <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/wifiadd')%>" method="post">
+ <input type="hidden" name="token" value="<%=token%>"/>
+ <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>"/>
+ <input type="hidden" name="ssid" value="<%=utl.pcdata(net.ssid)%>"/>
+ <input type="hidden" name="bssid" value="<%=utl.pcdata(net.bssid)%>"/>
+ <input type="hidden" name="wep" value="<%=net.encryption.wep and 1 or 0%>"/>
+ <%- if net.encryption.wpa then -%>
+ <input type="hidden" name="wpa_version" value="<%=net.encryption.wpa%>"/>
+ <%- for _, v in ipairs(net.encryption.auth_suites) do -%>
+ <input type="hidden" name="wpa_suites" value="<%=v%>"/>
+ <%- end -%>
+ <%- end -%>
+ <input class="cbi-button cbi-button-apply" type="submit" value="<%:Add Uplink%>"/>
+ </form>
+ </div>
+ </div>
+ <%- end -%>
+ </div>
+ </div>
+ <div class="cbi-page-actions right">
+ <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/stations')%>" method="get">
+ <input class="cbi-button cbi-button-reset" type="submit" value="<%:Back to overview%>"/>
+ </form>
+ <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/wifiscan')%>" method="post">
+ <input type="hidden" name="token" value="<%=token%>"/>
+ <input type="hidden" name="device" value="<%=utl.pcdata(dev)%>"/>
+ <input class="cbi-button cbi-input-find" type="submit" value="<%:Repeat scan%>"/>
+ </form>
+ </div>
</div>
<%+footer%>
diff --git a/applications/luci-app-unbound/luasrc/controller/unbound.lua b/applications/luci-app-unbound/luasrc/controller/unbound.lua
index 730ca724a4..ea3d26b919 100644
--- a/applications/luci-app-unbound/luasrc/controller/unbound.lua
+++ b/applications/luci-app-unbound/luasrc/controller/unbound.lua
@@ -1,151 +1,200 @@
-- Copyright 2008 Steven Barth <steven@midlink.org>
-- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
--- Copyright 2017 Eric Luehrsen <ericluehrsen@hotmail.com>
+-- Copyright 2017 Eric Luehrsen <ericluehrsen@gmail.com>
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.unbound", package.seeall)
function index()
- local ucl = luci.model.uci.cursor()
- local valexp = ucl:get_first("unbound", "unbound", "extended_luci")
- local valman = ucl:get_first("unbound", "unbound", "manual_conf")
+ local fs = require "nixio.fs"
+ local ucl = luci.model.uci.cursor()
+ local valman = ucl:get_first("unbound", "unbound", "manual_conf")
- if not nixio.fs.access("/etc/config/unbound") then
- return
- end
+ if not fs.access("/etc/config/unbound") then
+ return
+ end
- if valexp == "1" then
-- Expanded View
- entry({"admin", "services", "unbound"}, firstchild(), _("Recursive DNS")).dependent = false
+ entry({"admin", "services", "unbound"},
+ firstchild(), _("Recursive DNS")).dependent = false
-- UCI Tab(s)
- entry({"admin", "services", "unbound", "configure"}, cbi("unbound/configure"), _("Settings"), 10)
+ entry({"admin", "services", "unbound", "configure"},
+ cbi("unbound/configure"), _("Unbound"), 10)
+
+
+ if (valman == "0") then
+ entry({"admin", "services", "unbound", "zones"},
+ cbi("unbound/zones"), _("Zones"), 15)
+ end
+
-- Status Tab(s)
- entry({"admin", "services", "unbound", "status"}, firstchild(), _("Status"), 20)
- entry({"admin", "services", "unbound", "status", "syslog"}, call("QuerySysLog"), _("Log"), 50).leaf = true
+ entry({"admin", "services", "unbound", "status"},
+ firstchild(), _("Status"), 20)
+
+ entry({"admin", "services", "unbound", "status", "syslog"},
+ call("QuerySysLog"), _("Log"), 50).leaf = true
+
+
+ if fs.access("/usr/sbin/unbound-control") then
+ -- Require unbound-control to execute
+ entry({"admin", "services", "unbound", "status", "statistics"},
+ call("QueryStatistics"), _("Statistics"), 10).leaf = true
+ entry({"admin", "services", "unbound", "status", "localdata"},
+ call("QueryLocalData"), _("Local Data"), 20).leaf = true
- if nixio.fs.access("/usr/sbin/unbound-control") then
- -- Require unbound-control to execute
- entry({"admin", "services", "unbound", "status", "statistics"}, call("QueryStatistics"), _("Statistics"), 10).leaf = true
- entry({"admin", "services", "unbound", "status", "localdata"}, call("QueryLocalData"), _("Local Data"), 20).leaf = true
- entry({"admin", "services", "unbound", "status", "localzone"}, call("QueryLocalZone"), _("Local Zones"), 30).leaf = true
+ entry({"admin", "services", "unbound", "status", "localzone"},
+ call("QueryLocalZone"), _("Local Zones"), 30).leaf = true
else
- entry({"admin", "services", "unbound", "status", "statistics"}, call("ShowEmpty"), _("Statistics"), 10).leaf = true
+ entry({"admin", "services", "unbound", "status", "statistics"},
+ call("ShowEmpty"), _("Statistics"), 10).leaf = true
end
-- Raw File Tab(s)
- entry({"admin", "services", "unbound", "files"}, firstchild(), _("Files"), 30)
+ entry({"admin", "services", "unbound", "files"},
+ firstchild(), _("Files"), 30)
- if valman ~= "1" then
- entry({"admin", "services", "unbound", "files", "base"}, call("ShowUnboundConf"), _("UCI: Unbound"), 10).leaf = true
+ if (valman == "0") then
+ entry({"admin", "services", "unbound", "files", "uci"},
+ form("unbound/uciedit"), _("Edit: UCI"), 5).leaf = true
+
+ entry({"admin", "services", "unbound", "files", "base"},
+ call("ShowUnboundConf"), _("Show: Unbound"), 10).leaf = true
+
else
- entry({"admin", "services", "unbound", "files", "base"}, form("unbound/manual"), _("Edit: Unbound"), 10).leaf = true
+ entry({"admin", "services", "unbound", "files", "base"},
+ form("unbound/manual"), _("Edit: Unbound"), 10).leaf = true
end
- entry({"admin", "services", "unbound", "files", "server"}, form("unbound/server"), _("Edit: Server"), 20).leaf = true
- entry({"admin", "services", "unbound", "files", "extended"}, form("unbound/extended"), _("Edit: Extended"), 30).leaf = true
+ entry({"admin", "services", "unbound", "files", "server"},
+ form("unbound/server"), _("Edit: Server"), 20).leaf = true
+ entry({"admin", "services", "unbound", "files", "extended"},
+ form("unbound/extended"), _("Edit: Extended"), 30).leaf = true
- if nixio.fs.access("/var/lib/unbound/unbound_dhcp.conf") then
- entry({"admin", "services", "unbound", "files", "dhcp"}, call("ShowDHCPConf"), _("Include: DHCP"), 40).leaf = true
+
+ if fs.access("/var/lib/unbound/dhcp.conf") then
+ entry({"admin", "services", "unbound", "files", "dhcp"},
+ call("ShowDHCPConf"), _("Show: DHCP"), 40).leaf = true
end
- if nixio.fs.access("/var/lib/unbound/adb_list.overall") then
- entry({"admin", "services", "unbound", "files", "adblock"}, call("ShowAdblock"), _("Include: Adblock"), 50).leaf = true
+ if fs.access("/var/lib/unbound/adb_list.overall") then
+ entry({"admin", "services", "unbound", "files", "adblock"},
+ call("ShowAdblock"), _("Show: Adblock"), 50).leaf = true
end
-
- else
- -- Simple View to UCI only
- entry({"admin", "services", "unbound"}, cbi("unbound/configure"), _("Recursive DNS")).dependent = false
- end
end
function ShowEmpty()
- local lclhead = "Unbound Control"
- local lcldesc = luci.i18n.translate("This could display more statistics with the unbound-control package.")
- luci.template.render("unbound/show-empty", {heading = lclhead, description = lcldesc})
+ local lclhead = "Unbound Control"
+ local lcldesc = luci.i18n.translate(
+ "This could display more statistics with the unbound-control package.")
+
+ luci.template.render("unbound/show-empty",
+ {heading = lclhead, description = lcldesc})
end
function QuerySysLog()
- local lclhead = "System Log"
- local lcldata = luci.util.exec("logread | grep -i unbound")
- local lcldesc = luci.i18n.translate("This shows syslog filtered for events involving Unbound.")
- luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
+ local lcldata = luci.util.exec("logread | grep -i unbound")
+ local lcldesc = luci.i18n.translate(
+ "This shows syslog filtered for events involving Unbound.")
+
+ luci.template.render("unbound/show-textbox",
+ {heading = "", description = lcldesc, content = lcldata})
end
function QueryStatistics()
- local lclhead = "Unbound Control Stats"
- local lcldata = luci.util.exec("unbound-control -c /var/lib/unbound/unbound.conf stats_noreset")
- 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})
+ local lcldata = luci.util.exec(
+ "unbound-control -c /var/lib/unbound/unbound.conf stats_noreset")
+
+ local lcldesc = luci.i18n.translate(
+ "This shows Unbound self reported performance statistics.")
+
+ luci.template.render("unbound/show-textbox",
+ {heading = "", description = lcldesc, content = lcldata})
end
function QueryLocalData()
- local lclhead = "Unbound Control 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 host records that shortcut recursion.")
- luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
+ local lcldata = luci.util.exec(
+ "unbound-control -c /var/lib/unbound/unbound.conf list_local_data")
+
+ local lcldesc = luci.i18n.translate(
+ "This shows Unbound 'local-data:' entries from default, .conf, or control.")
+
+ luci.template.render("unbound/show-textbox",
+ {heading = "", description = lcldesc, content = lcldata})
end
function QueryLocalZone()
- local lclhead = "Unbound Control 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 zone definitions that affect recursion routing or processing. ")
- luci.template.render("unbound/show-textbox", {heading = lclhead, description = lcldesc, content = lcldata})
+ local lcldata = luci.util.exec(
+ "unbound-control -c /var/lib/unbound/unbound.conf list_local_zones")
+
+ local lcldesc = luci.i18n.translate(
+ "This shows Unbound 'local-zone:' entries from default, .conf, or control.")
+
+ luci.template.render("unbound/show-textbox",
+ {heading = "", description = lcldesc, content = lcldata})
end
function ShowUnboundConf()
- local unboundfile = "/var/lib/unbound/unbound.conf"
- local lclhead = "Unbound Conf"
- local lcldata = nixio.fs.readfile(unboundfile)
- 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})
+ local unboundfile = "/var/lib/unbound/unbound.conf"
+ local lcldata = nixio.fs.readfile(unboundfile)
+ local lcldesc = luci.i18n.translate(
+ "This shows '" .. unboundfile .. "' generated from UCI configuration.")
+
+ luci.template.render("unbound/show-textbox",
+ {heading = "", description = lcldesc, content = lcldata})
end
function ShowDHCPConf()
- local dhcpfile = "/var/lib/unbound/unbound_dhcp.conf"
- local lclhead = "DHCP Conf"
- local lcldata = nixio.fs.readfile(dhcpfile)
- 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})
+ local dhcpfile = "/var/lib/unbound/dhcp.conf"
+ local lcldata = nixio.fs.readfile(dhcpfile)
+ local lcldesc = luci.i18n.translate(
+ "This shows '" .. dhcpfile .. "' list of hosts from DHCP hook scripts.")
+
+ luci.template.render("unbound/show-textbox",
+ {heading = "", description = lcldesc, content = lcldata})
end
function ShowAdblock()
- local adblockfile = "/var/lib/unbound/adb_list.overall"
- local lclhead = "Adblock Conf"
- local lcldata, lcldesc
-
-
- 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})
- end
+ local fs = require "nixio.fs"
+ local tp = require "luci.template"
+ local tr = require "luci.i18n"
+ local adblockfile = "/var/lib/unbound/adb_list.overall"
+ local lcldata, lcldesc
+
+
+ if fs.stat(adblockfile).size > 262144 then
+ lcldesc = tr.translate(
+ "Adblock domain list '" .. adblockfile .. "' is too large for LuCI.")
+
+ tp.render("unbound/show-empty",
+ {heading = "", description = lcldesc})
+
+ else
+ lcldata = fs.readfile(adblockfile)
+ lcldesc = tr.translate(
+ "This shows '" .. adblockfile .. "' list of adblock domains." )
+
+ tp.render("unbound/show-textbox",
+ {heading = "", description = lcldesc, content = lcldata})
+ end
end
diff --git a/applications/luci-app-unbound/luasrc/model/cbi/unbound/configure.lua b/applications/luci-app-unbound/luasrc/model/cbi/unbound/configure.lua
index 256bbb8392..f665a2c9da 100644
--- a/applications/luci-app-unbound/luasrc/model/cbi/unbound/configure.lua
+++ b/applications/luci-app-unbound/luasrc/model/cbi/unbound/configure.lua
@@ -1,5 +1,5 @@
-- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
+-- Copyright 2016 Eric Luehrsen <ericluehrsen@gmail.com>
-- Copyright 2016 Dan Luedtke <mail@danrl.com>
-- Licensed to the public under the Apache License 2.0.
@@ -9,307 +9,312 @@ local rlh, rpv, vld, nvd, eds, prt, tlm
local ctl, dlk, dom, dty, lfq, wfq, exa
local dp6, d64, pfx, qry, qrs
local pro, tgr, rsc, rsn, ag2, stt
-local rpn, din, dfw, ath
+local rpn, din, ath
+
+local ut = require "luci.util"
+local sy = require "luci.sys"
+local ht = require "luci.http"
+local ds = require "luci.dispatcher"
local ucl = luci.model.uci.cursor()
local valman = ucl:get_first("unbound", "unbound", "manual_conf")
m1 = Map("unbound")
+s1 = m1:section(TypedSection, "unbound", translate("DNS Resolver"),
+ translatef("Unbound <a href=\"%s\" target=\"_blank\">(NLnet Labs)</a>"
+ .. " is a validating, recursive, and caching DNS resolver.",
+ "https://www.unbound.net/"))
-s1 = m1:section(TypedSection, "unbound")
s1.addremove = false
s1.anonymous = true
--LuCI, Unbound, or Not
-s1:tab("basic", translate("Basic"),
- translatef("<h3>Unbound Basic Settings</h3>\n"
- .. "<a href=\"%s\" target=\"_blank\">Unbound (link)</a>"
- .. " is a validating, recursive, and caching DNS resolver. "
- .. "UCI documentation can be found on "
- .. "<a href=\"%s\" target=\"_blank\">github (link)</a>.",
- "https://www.unbound.net/",
- "https://github.com/openwrt/packages/blob/master/net/unbound/files/README.md"))
-
-
-if valman ~= "1" then
- -- Not in manual configuration mode; show UCI
- s1:tab("advanced", translate("Advanced"),
- translatef("<h3>Unbound Advanced Settings</h3>\n"
- .. "Domain manipulation, lookup protection, and workarounds for "
- .. "<a href=\"%s\" target=\"_blank\">Unbound </a>"
- .. " DNS resolver.", "https://www.unbound.net/"))
-
- s1:tab("DHCP", translate("DHCP"),
- translatef("<h3>Unbound DHCP Settings</h3>\n"
- .. "Link your DHCP server to "
- .. "<a href=\"%s\" target=\"_blank\">Unbound </a>"
- .. " DNS resolver.", "https://www.unbound.net/ "))
-
- s1:tab("resource", translate("Resource"),
- translatef("<h3>Unbound Resource Settings</h3>\n"
- .. "Memory and protocol setttings for "
- .. "<a href=\"%s\" target=\"_blank\">Unbound </a>"
- .. " DNS resolver.", "https://www.unbound.net/"))
-end
+s1:tab("basic", translate("Basic"))
-s1:tab("trigger", translate("Trigger"),
- translatef("<h3>Unbound Event Trigger Settings</h3>\n"
- .. "Start, reload, and save RFC5011 DNSKEY records for "
- .. "<a href=\"%s\" target=\"_blank\">Unbound </a>"
- .. " DNS resolver.", "https://www.unbound.net/"))
+if (valman == "0") then
+ -- Not in manual configuration mode; show UCI
+ s1:tab("advanced", translate("Advanced"))
+ s1:tab("DHCP", translate("DHCP"))
+ s1:tab("resource", translate("Resource"))
+end
--Basic Tab, unconditional pieces
ena = s1:taboption("basic", Flag, "enabled", translate("Enable Unbound:"),
- translate("Enable the initialization scripts for Unbound"))
+ translate("Enable the initialization scripts for Unbound"))
ena.rmempty = false
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
-lci = s1:taboption("basic", Flag, "extended_luci", translate("Extended Tabs:"),
- translate("See detailed tabs for statistics, debug, and manual configuration"))
-lci.rmempty = false
-
-
-if valman ~= "1" then
- -- Not in manual configuration mode; show UCI
- --Basic Tab
- lsv = s1:taboption("basic", Flag, "localservice", translate("Local Service:"),
- translate("Accept queries only from local subnets"))
- lsv.rmempty = false
-
- vld = s1:taboption("basic", Flag, "validator", translate("Enable DNSSEC:"),
- translate("Enable the DNSSEC validator module"))
- vld.rmempty = false
-
- nvd = s1:taboption("basic", Flag, "validator_ntp", translate("DNSSEC NTP Fix:"),
- translate("Break the loop where DNSSEC needs NTP and NTP needs DNS"))
- nvd.rmempty = false
- nvd:depends({ validator = true })
-
- d64 = s1:taboption("basic", Flag, "dns64", translate("Enable DNS64:"),
- translate("Enable the DNS64 module"))
- d64.rmempty = false
-
- pfx = s1:taboption("basic", Value, "dns64_prefix", translate("DNS64 Prefix:"),
- translate("Prefix for generated DNS64 addresses"))
- pfx.datatype = "ip6addr"
- pfx.placeholder = "64:ff9b::/96"
- pfx.optional = true
- pfx:depends({ dns64 = true })
-
- prt = s1:taboption("basic", Value, "listen_port", translate("Listening Port:"),
- translate("Choose Unbounds listening port"))
- prt.datatype = "port"
- prt.rmempty = false
-
- --Avanced Tab
- din = s1:taboption("advanced", DynamicList, "domain_insecure",
- translate("Domain Insecure:"),
- translate("List domains to bypass checks of DNSSEC"))
- din:depends({ validator = true })
-
- dfw = s1:taboption("advanced", DynamicList, "domain_forward",
- translate("Domain Forward:"),
- translate("List domains to simply forward to stub resolvers in /tmp/resolve.auto"))
-
- rlh = s1:taboption("advanced", Flag, "rebind_localhost", translate("Filter Localhost Rebind:"),
- translate("Protect against upstream response of 127.0.0.0/8"))
- rlh.rmempty = false
-
- rpv = s1:taboption("advanced", ListValue, "rebind_protection", translate("Filter Private Rebind:"),
- translate("Protect against upstream responses within local subnets"))
- rpv:value("0", translate("No Filter"))
- rpv:value("1", translate("Filter RFC1918/4193"))
- rpv:value("2", translate("Filter Entire Subnet"))
- rpv.rmempty = false
-
- rpn = s1:taboption("advanced", Value, "rebind_interface", translate("Rebind Network Filter:"),
- translate("Network subnets to filter from upstream responses"))
- rpn.template = "cbi/network_netlist"
- rpn.widget = "checkbox"
- rpn.rmempty = true
- rpn.cast = "string"
- rpn.nocreate = true
- rpn:depends({ rebind_protection = 2 })
- rpn:depends({ rebind_protection = 3 })
-
- --DHCP Tab
- dlk = s1:taboption("DHCP", ListValue, "dhcp_link", translate("DHCP Link:"),
- translate("Link to supported programs to load DHCP into DNS"))
- dlk:value("none", translate("No Link"))
- dlk:value("dnsmasq", "dnsmasq")
- dlk:value("odhcpd", "odhcpd")
- dlk.rmempty = false
-
- dp6 = s1:taboption("DHCP", Flag, "dhcp4_slaac6", translate("DHCPv4 to SLAAC:"),
- translate("Use DHCPv4 MAC to discover IP6 hosts SLAAC (EUI64)"))
- dp6.rmempty = false
- dp6:depends({ dhcp_link = "odhcpd" })
-
- dom = s1:taboption("DHCP", Value, "domain", translate("Local Domain:"),
- translate("Domain suffix for this router and DHCP clients"))
- dom.placeholder = "lan"
- dom:depends({ dhcp_link = "none" })
- dom:depends({ dhcp_link = "odhcpd" })
-
- dty = s1:taboption("DHCP", ListValue, "domain_type", translate("Local Domain Type:"),
- translate("How to treat queries of this local domain"))
- dty:value("deny", translate("Ignored"))
- dty:value("refuse", translate("Refused"))
- dty:value("static", translate("Only Local"))
- dty:value("transparent", translate("Also Forwarded"))
- dty:depends({ dhcp_link = "none" })
- dty:depends({ dhcp_link = "odhcpd" })
-
- lfq = s1:taboption("DHCP", ListValue, "add_local_fqdn", translate("LAN DNS:"),
- translate("How to enter the LAN or local network router in DNS"))
- lfq:value("0", translate("No Entry"))
- lfq:value("1", translate("Hostname, Primary Address"))
- lfq:value("2", translate("Hostname, All Addresses"))
- lfq:value("3", translate("Host FQDN, All Addresses"))
- lfq:value("4", translate("Interface FQDN, All Addresses"))
- lfq:depends({ dhcp_link = "none" })
- lfq:depends({ dhcp_link = "odhcpd" })
-
- wfq = s1:taboption("DHCP", ListValue, "add_wan_fqdn", translate("WAN DNS:"),
- translate("Override the WAN side router entry in DNS"))
- wfq:value("0", translate("Use Upstream"))
- wfq:value("1", translate("Hostname, Primary Address"))
- wfq:value("2", translate("Hostname, All Addresses"))
- wfq:value("3", translate("Host FQDN, All Addresses"))
- wfq:value("4", translate("Interface FQDN, All Addresses"))
- wfq:depends({ dhcp_link = "none" })
- wfq:depends({ dhcp_link = "odhcpd" })
-
- exa = s1:taboption("DHCP", ListValue, "add_extra_dns", translate("Extra DNS:"),
- translate("Use extra DNS entries found in /etc/config/dhcp"))
- exa:value("0", translate("Ignore"))
- exa:value("1", translate("Include Network/Hostnames"))
- exa:value("2", translate("Advanced MX/SRV RR"))
- exa:value("3", translate("Advanced CNAME RR"))
- exa:depends({ dhcp_link = "none" })
- exa:depends({ dhcp_link = "odhcpd" })
-
- --TODO: dnsmasq needs to not reference resolve-file and get off port 53.
-
- --Resource Tuning Tab
- ctl = s1:taboption("resource", ListValue, "unbound_control", translate("Unbound Control App:"),
- translate("Enable access for unbound-control"))
- 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"))
-
- pro = s1:taboption("resource", ListValue, "protocol", translate("Recursion Protocol:"),
- translate("Chose the protocol recursion queries leave on"))
- pro:value("default", translate("Default"))
- pro:value("ip4_only", translate("IP4 Only"))
- pro:value("ip6_only", translate("IP6 Only"))
- pro:value("ip6_prefer", translate("IP6 Preferred"))
- pro:value("mixed", translate("IP4 and IP6"))
- pro.rmempty = false
-
- rsc = s1:taboption("resource", ListValue, "resource", translate("Memory Resource:"),
- translate("Use menu System/Processes to observe any memory growth"))
- rsc:value("default", translate("Default"))
- rsc:value("tiny", translate("Tiny"))
- rsc:value("small", translate("Small"))
- rsc:value("medium", translate("Medium"))
- rsc:value("large", translate("Large"))
- rsc.rmempty = false
-
- rsn = s1:taboption("resource", ListValue, "recursion", translate("Recursion Strength:"),
- translate("Recursion activity affects memory growth and CPU load"))
- rsn:value("default", translate("Default"))
- rsn:value("passive", translate("Passive"))
- rsn:value("aggressive", translate("Aggressive"))
- rsn.rmempty = false
-
- qry = s1:taboption("resource", Flag, "query_minimize", translate("Query Minimize:"),
- translate("Break down query components for limited added privacy"))
- qry.rmempty = false
- qry:depends({ recursion = "passive" })
- qry:depends({ recursion = "aggressive" })
-
- qrs = s1:taboption("resource", Flag, "query_min_strict", translate("Strict Minimize:"),
- translate("Strict version of 'query minimize' but it can break DNS"))
- qrs.rmempty = false
- qrs:depends({ query_minimize = true })
-
- ath = s1:taboption("resource", Flag, "prefetch_root", translate("Prefetch Root:"),
- translate("Obtain complete root zone files and install in auth-zone: clause"))
- ath.rmempty = false
-
- eds = s1:taboption("resource", Value, "edns_size", translate("EDNS Size:"),
- translate("Limit extended DNS packet size"))
- eds.datatype = "and(uinteger,min(512),max(4096))"
- eds.rmempty = false
-
- tlm = s1:taboption("resource", Value, "ttl_min", translate("TTL Minimum:"),
- translate("Prevent excessively short cache periods"))
- tlm.datatype = "and(uinteger,min(0),max(600))"
- tlm.rmempty = false
-
- stt = s1:taboption("resource", Flag, "extended_stats", translate("Extended Statistics:"),
- translate("Extended statistics are printed from unbound-control"))
- stt.rmempty = false
-end
-
-
---Trigger Tab, always unconditional
-ag2 = s1:taboption("trigger", Value, "root_age", translate("Root DSKEY Age:"),
- translate("Limit days between RFC5011 copies to reduce flash writes"))
-ag2.datatype = "and(uinteger,min(1),max(99))"
-ag2:value("3", "3")
-ag2:value("9", "9 ("..translate("default")..")")
-ag2:value("12", "12")
-ag2:value("24", "24")
-ag2:value("99", "99 ("..translate("never")..")")
-tgr = s1:taboption("trigger", Value, "trigger_interface", translate("Trigger Networks:"),
- translate("Networks that may trigger Unbound to reload (avoid wan6)"))
-tgr.template = "cbi/network_netlist"
-tgr.widget = "checkbox"
-tgr.rmempty = true
-tgr.cast = "string"
-tgr.nocreate = true
+if (valman == "0") then
+ -- Not in manual configuration mode; show UCI
+ --Basic Tab
+ lsv = s1:taboption("basic", Flag, "localservice",
+ translate("Local Service:"),
+ translate("Accept queries only from local subnets"))
+ lsv.rmempty = false
+
+ vld = s1:taboption("basic", Flag, "validator",
+ translate("Enable DNSSEC:"),
+ translate("Enable the DNSSEC validator module"))
+ vld.rmempty = false
+
+ nvd = s1:taboption("basic", Flag, "validator_ntp",
+ translate("DNSSEC NTP Fix:"),
+ translate("Break the loop where DNSSEC needs NTP and NTP needs DNS"))
+ nvd.rmempty = false
+ nvd:depends({ validator = true })
+
+ prt = s1:taboption("basic", Value, "listen_port",
+ translate("Listening Port:"),
+ translate("Choose Unbounds listening port"))
+ prt.datatype = "port"
+ prt.rmempty = false
+
+ --Avanced Tab
+ rlh = s1:taboption("advanced", Flag, "rebind_localhost",
+ translate("Filter Localhost Rebind:"),
+ translate("Protect against upstream response of 127.0.0.0/8"))
+ rlh.rmempty = false
+
+ rpv = s1:taboption("advanced", ListValue, "rebind_protection",
+ translate("Filter Private Rebind:"),
+ translate("Protect against upstream responses within local subnets"))
+ rpv:value("0", translate("No Filter"))
+ rpv:value("1", translate("Filter RFC1918/4193"))
+ rpv:value("2", translate("Filter Entire Subnet"))
+ rpv.rmempty = false
+
+ d64 = s1:taboption("advanced", Flag, "dns64", translate("Enable DNS64:"),
+ translate("Enable the DNS64 module"))
+ d64.rmempty = false
+
+ pfx = s1:taboption("advanced", Value, "dns64_prefix",
+ translate("DNS64 Prefix:"),
+ translate("Prefix for generated DNS64 addresses"))
+ pfx.datatype = "ip6addr"
+ pfx.placeholder = "64:ff9b::/96"
+ pfx.optional = true
+ pfx:depends({ dns64 = true })
+
+ din = s1:taboption("advanced", DynamicList, "domain_insecure",
+ translate("Domain Insecure:"),
+ translate("List domains to bypass checks of DNSSEC"))
+ din:depends({ validator = true })
+
+ ag2 = s1:taboption("advanced", Value, "root_age",
+ translate("Root DSKEY Age:"),
+ translate("Limit days between RFC5011 copies to reduce flash writes"))
+ ag2.datatype = "and(uinteger,min(1),max(99))"
+ ag2:value("3", "3")
+ ag2:value("9", "9 ("..translate("default")..")")
+ ag2:value("12", "12")
+ ag2:value("24", "24")
+ ag2:value("99", "99 ("..translate("never")..")")
+
+ tgr = s1:taboption("advanced", Value, "trigger_interface",
+ translate("Trigger Networks:"),
+ translate("Networks that may trigger Unbound to reload (avoid wan6)"))
+ tgr.template = "cbi/network_netlist"
+ tgr.widget = "checkbox"
+ tgr.rmempty = true
+ tgr.cast = "string"
+ tgr.nocreate = true
+
+ --DHCP Tab
+ dlk = s1:taboption("DHCP", ListValue, "dhcp_link",
+ translate("DHCP Link:"),
+ translate("Link to supported programs to load DHCP into DNS"))
+ dlk:value("none", translate("No Link"))
+ dlk:value("dnsmasq", "dnsmasq")
+ dlk:value("odhcpd", "odhcpd")
+ dlk.rmempty = false
+
+ dp6 = s1:taboption("DHCP", Flag, "dhcp4_slaac6",
+ translate("DHCPv4 to SLAAC:"),
+ translate("Use DHCPv4 MAC to discover IP6 hosts SLAAC (EUI64)"))
+ dp6.rmempty = false
+ dp6:depends({ dhcp_link = "odhcpd" })
+
+ dom = s1:taboption("DHCP", Value, "domain",
+ translate("Local Domain:"),
+ translate("Domain suffix for this router and DHCP clients"))
+ dom.placeholder = "lan"
+ dom:depends({ dhcp_link = "none" })
+ dom:depends({ dhcp_link = "odhcpd" })
+
+ dty = s1:taboption("DHCP", ListValue, "domain_type",
+ translate("Local Domain Type:"),
+ translate("How to treat queries of this local domain"))
+ dty:value("deny", translate("Denied (nxdomain)"))
+ dty:value("refuse", translate("Refused"))
+ dty:value("static", translate("Static (local only)"))
+ dty:value("transparent", translate("Transparent (local/global)"))
+ dty:depends({ dhcp_link = "none" })
+ dty:depends({ dhcp_link = "odhcpd" })
+
+ lfq = s1:taboption("DHCP", ListValue, "add_local_fqdn",
+ translate("LAN DNS:"),
+ translate("How to enter the LAN or local network router in DNS"))
+ lfq:value("0", translate("No Entry"))
+ lfq:value("1", translate("Hostname, Primary Address"))
+ lfq:value("2", translate("Hostname, All Addresses"))
+ lfq:value("3", translate("Host FQDN, All Addresses"))
+ lfq:value("4", translate("Interface FQDN, All Addresses"))
+ lfq:depends({ dhcp_link = "none" })
+ lfq:depends({ dhcp_link = "odhcpd" })
+
+ wfq = s1:taboption("DHCP", ListValue, "add_wan_fqdn",
+ translate("WAN DNS:"),
+ translate("Override the WAN side router entry in DNS"))
+ wfq:value("0", translate("Use Upstream"))
+ wfq:value("1", translate("Hostname, Primary Address"))
+ wfq:value("2", translate("Hostname, All Addresses"))
+ wfq:value("3", translate("Host FQDN, All Addresses"))
+ wfq:value("4", translate("Interface FQDN, All Addresses"))
+ wfq:depends({ dhcp_link = "none" })
+ wfq:depends({ dhcp_link = "odhcpd" })
+
+ exa = s1:taboption("DHCP", ListValue, "add_extra_dns",
+ translate("Extra DNS:"),
+ translate("Use extra DNS entries found in /etc/config/dhcp"))
+ exa:value("0", translate("Ignore"))
+ exa:value("1", translate("Host Records"))
+ exa:value("2", translate("Host/MX/SRV RR"))
+ exa:value("3", translate("Host/MX/SRV/CNAME RR"))
+ exa:depends({ dhcp_link = "none" })
+ exa:depends({ dhcp_link = "odhcpd" })
+
+ --TODO: dnsmasq needs to not reference resolve-file and get off port 53.
+
+ --Resource Tuning Tab
+ ctl = s1:taboption("resource", ListValue, "unbound_control",
+ translate("Unbound Control App:"),
+ translate("Enable access for unbound-control"))
+ 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"))
+
+ pro = s1:taboption("resource", ListValue, "protocol",
+ translate("Recursion Protocol:"),
+ translate("Chose the protocol recursion queries leave on"))
+ pro:value("default", translate("Default"))
+ pro:value("ip4_only", translate("IP4 Only"))
+ pro:value("ip6_only", translate("IP6 Only"))
+ pro:value("ip6_prefer", translate("IP6 Preferred"))
+ pro:value("mixed", translate("IP4 and IP6"))
+ pro.rmempty = false
+
+ rsc = s1:taboption("resource", ListValue, "resource",
+ translate("Memory Resource:"),
+ translate("Use menu System/Processes to observe any memory growth"))
+ rsc:value("default", translate("Default"))
+ rsc:value("tiny", translate("Tiny"))
+ rsc:value("small", translate("Small"))
+ rsc:value("medium", translate("Medium"))
+ rsc:value("large", translate("Large"))
+ rsc.rmempty = false
+
+ rsn = s1:taboption("resource", ListValue, "recursion",
+ translate("Recursion Strength:"),
+ translate("Recursion activity affects memory growth and CPU load"))
+ rsn:value("default", translate("Default"))
+ rsn:value("passive", translate("Passive"))
+ rsn:value("aggressive", translate("Aggressive"))
+ rsn.rmempty = false
+
+ qry = s1:taboption("resource", Flag, "query_minimize",
+ translate("Query Minimize:"),
+ translate("Break down query components for limited added privacy"))
+ qry.rmempty = false
+ qry:depends({ recursion = "passive" })
+ qry:depends({ recursion = "aggressive" })
+
+ qrs = s1:taboption("resource", Flag, "query_min_strict",
+ translate("Strict Minimize:"),
+ translate("Strict version of 'query minimize' but it can break DNS"))
+ qrs.rmempty = false
+ qrs:depends({ query_minimize = true })
+
+ eds = s1:taboption("resource", Value, "edns_size",
+ translate("EDNS Size:"),
+ translate("Limit extended DNS packet size"))
+ eds.datatype = "and(uinteger,min(512),max(4096))"
+ eds.rmempty = false
+
+ tlm = s1:taboption("resource", Value, "ttl_min",
+ translate("TTL Minimum:"),
+ translate("Prevent excessively short cache periods"))
+ tlm.datatype = "and(uinteger,min(0),max(600))"
+ tlm.rmempty = false
+
+ stt = s1:taboption("resource", Flag, "extended_stats",
+ translate("Extended Statistics:"),
+ translate("Extended statistics are printed from unbound-control"))
+ stt.rmempty = false
+
+else
+ ag2 = s1:taboption("basic", Value, "root_age",
+ translate("Root DSKEY Age:"),
+ translate("Limit days between RFC5011 copies to reduce flash writes"))
+ ag2.datatype = "and(uinteger,min(1),max(99))"
+ ag2:value("3", "3")
+ ag2:value("9", "9 ("..translate("default")..")")
+ ag2:value("12", "12")
+ ag2:value("24", "24")
+ ag2:value("99", "99 ("..translate("never")..")")
+
+ tgr = s1:taboption("basic", Value, "trigger_interface",
+ translate("Trigger Networks:"),
+ translate("Networks that may trigger Unbound to reload (avoid wan6)"))
+ tgr.template = "cbi/network_netlist"
+ tgr.widget = "checkbox"
+ tgr.rmempty = true
+ tgr.cast = "string"
+ tgr.nocreate = true
+end
function ena.cfgvalue(self, section)
- return luci.sys.init.enabled("unbound") and self.enabled or self.disabled
+ return sy.init.enabled("unbound") and self.enabled or self.disabled
end
function ena.write(self, section, value)
- if value == "1" then
- luci.sys.init.enable("unbound")
- luci.sys.call("/etc/init.d/unbound start >/dev/null")
- else
- luci.sys.call("/etc/init.d/unbound stop >/dev/null")
- luci.sys.init.disable("unbound")
- end
-
- return Flag.write(self, section, value)
+ if (value == "1") then
+ sy.init.enable("unbound")
+ sy.call("/etc/init.d/unbound start >/dev/null 2>&1")
+
+ else
+ sy.call("/etc/init.d/unbound stop >/dev/null 2>&1")
+ sy.init.disable("unbound")
+ end
+
+
+ return Flag.write(self, section, value)
end
-function m1.on_apply(self)
- function ena.validate(self, value)
- if value ~= "0" then
- luci.sys.call("/etc/init.d/unbound restart >/dev/null 2>&1")
+function m1.on_commit(self)
+ if sy.init.enabled("unbound") then
+ -- Restart Unbound with configuration
+ sy.call("/etc/init.d/unbound restart >/dev/null 2>&1")
+
else
- luci.sys.call("/etc/init.d/unbound stop >/dev/null 2>&1")
+ sy.call("/etc/init.d/unbound stop >/dev/null 2>&1")
end
- end
+end
- -- Restart Unbound with configuration and reload the page (some options hide)
- luci.http.redirect(luci.dispatcher.build_url("admin", "services", "unbound"))
+function m1.on_apply(self)
+ -- reload the page because some options hide
+ ht.redirect(ds.build_url("admin", "services", "unbound", "configure"))
end
diff --git a/applications/luci-app-unbound/luasrc/model/cbi/unbound/extended.lua b/applications/luci-app-unbound/luasrc/model/cbi/unbound/extended.lua
index 67d2ec6c6b..6c5e8c23ef 100644
--- a/applications/luci-app-unbound/luasrc/model/cbi/unbound/extended.lua
+++ b/applications/luci-app-unbound/luasrc/model/cbi/unbound/extended.lua
@@ -1,28 +1,31 @@
--- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
+-- Copyright 2016 Eric Luehrsen <ericluehrsen@gmail.com>
-- Licensed to the public under the Apache License 2.0.
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 .. ")"
+local fs = require "nixio.fs"
+local ut = require "luci.util"
m4 = SimpleForm("editing", nil)
m4:append(Template("unbound/css-editing"))
m4.submit = translate("Save")
m4.reset = false
-s4 = m4:section(SimpleSection, "Unbound Extended Conf", description)
+s4 = m4:section(SimpleSection, "",
+ translatef(
+ "Edit clauses such as 'forward-zone:' for 'include: " .. filename .. "'"))
+
frm = s4:option(TextValue, "data")
frm.datatype = "string"
frm.rows = 20
function frm.cfgvalue()
- return nixio.fs.readfile(filename) or ""
+ return fs.readfile(filename) or ""
end
function frm.write(self, section, data)
- return nixio.fs.writefile(filename, luci.util.trim(data:gsub("\r\n", "\n")))
+ return fs.writefile(filename, ut.trim(data:gsub("\r\n", "\n")))
end
diff --git a/applications/luci-app-unbound/luasrc/model/cbi/unbound/manual.lua b/applications/luci-app-unbound/luasrc/model/cbi/unbound/manual.lua
index 5cfb9c32c1..317c23fda0 100644
--- a/applications/luci-app-unbound/luasrc/model/cbi/unbound/manual.lua
+++ b/applications/luci-app-unbound/luasrc/model/cbi/unbound/manual.lua
@@ -1,28 +1,31 @@
--- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
+-- Copyright 2016 Eric Luehrsen <ericluehrsen@gmail.com>
-- Licensed to the public under the Apache License 2.0.
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 .. ")"
+local fs = require "nixio.fs"
+local ut = require "luci.util"
m2 = SimpleForm("editing", nil)
m2:append(Template("unbound/css-editing"))
m2.submit = translate("Save")
m2.reset = false
-s2 = m2:section(SimpleSection, "Unbound Conf", description)
+s2 = m2:section(SimpleSection, "",
+ translatef(
+ "Edit '" .. filename .. "' when you do not use UCI."))
+
frm = s2:option(TextValue, "data")
frm.datatype = "string"
frm.rows = 20
function frm.cfgvalue()
- return nixio.fs.readfile(filename) or ""
+ return fs.readfile(filename) or ""
end
function frm.write(self, section, data)
- return nixio.fs.writefile(filename, luci.util.trim(data:gsub("\r\n", "\n")))
+ return fs.writefile(filename, ut.trim(data:gsub("\r\n", "\n")))
end
diff --git a/applications/luci-app-unbound/luasrc/model/cbi/unbound/server.lua b/applications/luci-app-unbound/luasrc/model/cbi/unbound/server.lua
index d0ac407847..5cef2a67b0 100644
--- a/applications/luci-app-unbound/luasrc/model/cbi/unbound/server.lua
+++ b/applications/luci-app-unbound/luasrc/model/cbi/unbound/server.lua
@@ -1,28 +1,31 @@
--- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
+-- Copyright 2016 Eric Luehrsen <ericluehrsen@gmail.com>
-- Licensed to the public under the Apache License 2.0.
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 .. ")"
+local fs = require "nixio.fs"
+local ut = require "luci.util"
m3 = SimpleForm("editing", nil)
m3:append(Template("unbound/css-editing"))
m3.submit = translate("Save")
m3.reset = false
-s3 = m3:section(SimpleSection, "Unbound Server Conf", description)
+s3 = m3:section(SimpleSection, "",
+ translatef(
+ "Edit 'server:' clause options for 'include: " .. filename .. "'"))
+
frm = s3:option(TextValue, "data")
frm.datatype = "string"
frm.rows = 20
function frm.cfgvalue()
- return nixio.fs.readfile(filename) or ""
+ return fs.readfile(filename) or ""
end
function frm.write(self, section, data)
- return nixio.fs.writefile(filename, luci.util.trim(data:gsub("\r\n", "\n")))
+ return fs.writefile(filename, ut.trim(data:gsub("\r\n", "\n")))
end
diff --git a/applications/luci-app-unbound/luasrc/model/cbi/unbound/uciedit.lua b/applications/luci-app-unbound/luasrc/model/cbi/unbound/uciedit.lua
new file mode 100644
index 0000000000..3aef189652
--- /dev/null
+++ b/applications/luci-app-unbound/luasrc/model/cbi/unbound/uciedit.lua
@@ -0,0 +1,37 @@
+-- Copyright 2016 Eric Luehrsen <ericluehrsen@gmail.com>
+-- Licensed to the public under the Apache License 2.0.
+
+local m6, s6, frm
+local filename = "/etc/config/unbound"
+local fs = require "nixio.fs"
+local ut = require "luci.util"
+
+m6 = SimpleForm("editing", nil)
+m6:append(Template("unbound/css-editing"))
+m6.submit = translate("Save")
+m6.reset = false
+s6 = m6:section(SimpleSection, "",
+ translatef("Edit '" .. filename .. "' "
+ .. "and help can be found in OpenWrt "
+ .. "<a href=\"%s\" target=\"_blank\">Guides</a> "
+ .. "and <a href=\"%s\" target=\"_blank\">Github</a>.",
+ "https://openwrt.org/docs/guide-user/services/dns/unbound",
+ "https://github.com/openwrt/packages/blob/master/net/unbound/files/README.md"))
+
+frm = s6:option(TextValue, "data")
+frm.datatype = "string"
+frm.rows = 20
+
+
+function frm.cfgvalue()
+ return fs.readfile(filename) or ""
+end
+
+
+function frm.write(self, section, data)
+ return fs.writefile(filename, ut.trim(data:gsub("\r\n", "\n")))
+end
+
+
+return m6
+
diff --git a/applications/luci-app-unbound/luasrc/model/cbi/unbound/zones.lua b/applications/luci-app-unbound/luasrc/model/cbi/unbound/zones.lua
new file mode 100644
index 0000000000..bbc0e2335f
--- /dev/null
+++ b/applications/luci-app-unbound/luasrc/model/cbi/unbound/zones.lua
@@ -0,0 +1,207 @@
+-- Copyright 2017 Eric Luehrsen <ericluehrsen@gmail.com>
+-- Licensed to the public under the Apache License 2.0.
+
+local m5, s5
+local ztype, zones, servers, fallback, enabled
+
+local fs = require "nixio.fs"
+local ut = require "luci.util"
+local sy = require "luci.sys"
+local resolvfile = "/tmp/resolv.conf.auto"
+
+m5 = Map("unbound")
+s5 = m5:section(TypedSection, "zone", "Zones",
+ translatef("This shows extended zones and more details can be "
+ .. "changed in Files tab and <a href=\"%s\">Edit:UCI</a> subtab.",
+ "/cgi-bin/luci/admin/services/unbound/files" ))
+
+s5.addremove = false
+s5.anonymous = true
+s5.sortable = true
+s5.template = "cbi/tblsection"
+
+ztype = s5:option(DummyValue, "DummyType", translate("Type"))
+ztype.rawhtml = true
+
+zones = s5:option(DummyValue, "DummyZones", translate("Zones"))
+zones.rawhtml = true
+
+servers = s5:option(DummyValue, "DummyServers", translate("Servers"))
+servers.rawhtml = true
+
+fallback = s5:option(Flag, "fallback", translate("Fallback"))
+fallback.rmempty = false
+
+enabled = s5:option(Flag, "enabled", translate("Enable"))
+enabled.rmempty = false
+
+
+function ztype.cfgvalue(self, s)
+ -- Format a meaninful tile for the Zone Type column
+ local itxt = self.map:get(s, "zone_type")
+ local itls = self.map:get(s, "tls_upstream")
+
+
+ if itxt and itxt:match("forward") then
+ if itls and (itls == "1") then
+ return translate("Forward TLS")
+
+ else
+ return translate("Forward")
+ end
+
+ elseif itxt and itxt:match("stub") then
+ return translate("Recurse")
+
+ elseif itxt and itxt:match("auth") then
+ return translate("AXFR")
+
+ else
+ return translate("Error")
+ end
+end
+
+
+function zones.cfgvalue(self, s)
+ -- Format a meaninful sentence for the Zones viewed column
+ local xtxt, otxt
+ local itxt = self.map:get(s, "zone_name")
+ local itype = self.map:get(s, "zone_type")
+
+
+ for xtxt in ut.imatch(itxt) do
+ if (xtxt == ".") then
+ -- zone_name lists
+ xtxt = translate("(root)")
+ end
+
+
+ if otxt and (#otxt > 0) then
+ otxt = otxt .. ", <var>%s</var>" % xtxt
+
+ else
+ otxt = "<var>%s</var>" % xtxt
+ end
+ end
+
+
+ if itype and itype:match("forward") then
+ -- from zone_type create a readable hint for the action
+ otxt = translate("accept upstream results for ") .. otxt
+
+ elseif itype and itype:match("stub") then
+ otxt = translate("select recursion for ") .. otxt
+
+ elseif itype and itype:match("auth") then
+ otxt = translate("prefetch zone files for ") .. otxt
+
+ else
+ otxt = translate("unknown action for ") .. otxt
+ end
+
+
+ if otxt and (#otxt > 0) then
+ return otxt
+
+ else
+ return "(empty)"
+ end
+end
+
+
+function servers.cfgvalue(self, s)
+ -- Format a meaninful sentence for the Servers (and URL) column
+ local xtxt, otxt, rtxt, found
+ local itxt = self.map:get(s, "server")
+ local iurl = self.map:get(s, "url_dir")
+ local itype = self.map:get(s, "zone_type")
+ local itls = self.map:get(s, "tls_upstream")
+ local iidx = self.map:get(s, "tls_index")
+ local irslv = self.map:get(s, "resolv_conf")
+
+
+ for xtxt in ut.imatch(itxt) do
+ if otxt and (#otxt > 0) then
+ -- bundle and make pretty the server list
+ otxt = otxt .. ", <var>%s</var>" % xtxt
+
+ else
+ otxt = "<var>%s</var>" % xtxt
+ end
+ end
+
+
+ if otxt and (#otxt > 0)
+ and itls and (itls == "1")
+ and iidx and (#iidx > 0) then
+ -- show TLS certificate name index if provided
+ otxt = translatef("use nameservers by <var>%s</var> at ", iidx) .. otxt
+
+ elseif otxt and (#otxt > 0) then
+ otxt = translate("use nameservers ") .. otxt
+ end
+
+
+ if iurl and (#iurl > 0) and itype and itype:match("auth") then
+ if otxt and (#otxt > 0) then
+ -- include optional URL filed for auth-zone: type
+ otxt = otxt .. translatef(", and try <var>%s</var>", iurl)
+
+ else
+ otxt = translatef("download from <var>%s</var>", iurl)
+ end
+ end
+
+
+ if irslv and (irslv == "1") and itype and itype:match("forward") then
+ for xtxt in ut.imatch(fs.readfile(resolvfile)) do
+ if xtxt:match("nameserver") then
+ found = true
+
+ elseif (found == true) then
+ if rtxt and (#rtxt > 0) then
+ -- fetch name servers from resolv.conf
+ rtxt = rtxt .. ", <var>%s</var>" % xtxt
+
+ else
+ rtxt = "<var>%s</var>" % xtxt
+ end
+
+
+ found = false
+ end
+ end
+
+
+ if otxt and (#otxt > 0) and rtxt and (#rtxt > 0) then
+ otxt = otxt
+ .. translatef(", and <var>%s</var> entries ", resolvfile) .. rtxt
+
+ elseif rtxt and (#rtxt > 0) then
+ otxt = translatef("use <var>%s</var> nameservers ", resolvfile) .. rtxt
+ end
+ end
+
+
+ if otxt and (#otxt > 0) then
+ return otxt
+
+ else
+ return "(empty)"
+ end
+end
+
+
+function m5.on_commit(self)
+ if sy.init.enabled("unbound") then
+ -- Restart Unbound with configuration
+ sy.call("/etc/init.d/unbound restart >/dev/null 2>&1")
+
+ else
+ sy.call("/etc/init.d/unbound stop >/dev/null 2>&1")
+ end
+end
+
+
+return m5
+
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
index db8535086f..a56d904d9f 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
@@ -221,63 +221,36 @@
<% end %>
<% if has_dsl then %>
- var dsl_i = document.getElementById('dsl_i');
- var dsl_s = document.getElementById('dsl_s');
-
- var s = String.format(
- '<strong><%:Status%>: </strong>%s<br />' +
- '<strong><%:Line State%>: </strong>%s [0x%x]<br />' +
- '<strong><%:Line Mode%>: </strong>%s<br />' +
- '<strong><%:Annex%>: </strong>%s<br />' +
- '<strong><%:Profile%>: </strong>%s<br />' +
- '<strong><%:Data Rate%>: </strong>%s/s / %s/s<br />' +
- '<strong><%:Max. Attainable Data Rate (ATTNDR)%>: </strong>%s/s / %s/s<br />' +
- '<strong><%:Latency%>: </strong>%s / %s<br />' +
- '<strong><%:Line Attenuation (LATN)%>: </strong>%s dB / %s dB<br />' +
- '<strong><%:Signal Attenuation (SATN)%>: </strong>%s dB / %s dB<br />' +
- '<strong><%:Noise Margin (SNR)%>: </strong>%s dB / %s dB<br />' +
- '<strong><%:Aggregate Transmit Power(ACTATP)%>: </strong>%s dB / %s dB<br />' +
- '<strong><%:Forward Error Correction Seconds (FECS)%>: </strong>%s / %s<br />' +
- '<strong><%:Errored seconds (ES)%>: </strong>%s / %s<br />' +
- '<strong><%:Severely Errored Seconds (SES)%>: </strong>%s / %s<br />' +
- '<strong><%:Loss of Signal Seconds (LOSS)%>: </strong>%s / %s<br />' +
- '<strong><%:Unavailable Seconds (UAS)%>: </strong>%s / %s<br />' +
- '<strong><%:Header Error Code Errors (HEC)%>: </strong>%s / %s<br />' +
- '<strong><%:Non Pre-emtive CRC errors (CRC_P)%>: </strong>%s / %s<br />' +
- '<strong><%:Pre-emtive CRC errors (CRCP_P)%>: </strong>%s / %s<br />' +
- '<strong><%:Line Uptime%>: </strong>%s<br />' +
- '<strong><%:ATU-C System Vendor ID%>: </strong>%s<br />' +
- '<strong><%:Power Management Mode%>: </strong>%s<br />',
- info.dsl.line_state, info.dsl.line_state_detail,
- info.dsl.line_state_num,
- info.dsl.line_mode_s,
- info.dsl.annex_s,
- info.dsl.profile_s,
- info.dsl.data_rate_down_s, info.dsl.data_rate_up_s,
- info.dsl.max_data_rate_down_s, info.dsl.max_data_rate_up_s,
- info.dsl.latency_num_down, info.dsl.latency_num_up,
- info.dsl.line_attenuation_down, info.dsl.line_attenuation_up,
- info.dsl.signal_attenuation_down, info.dsl.signal_attenuation_up,
- info.dsl.noise_margin_down, info.dsl.noise_margin_up,
- info.dsl.actatp_down, info.dsl.actatp_up,
- info.dsl.errors_fec_near, info.dsl.errors_fec_far,
- info.dsl.errors_es_near, info.dsl.errors_es_far,
- info.dsl.errors_ses_near, info.dsl.errors_ses_far,
- info.dsl.errors_loss_near, info.dsl.errors_loss_far,
- info.dsl.errors_uas_near, info.dsl.errors_uas_far,
- info.dsl.errors_hec_near, info.dsl.errors_hec_far,
- info.dsl.errors_crc_p_near, info.dsl.errors_crc_p_far,
- info.dsl.errors_crcp_p_near, info.dsl.errors_crcp_p_far,
- info.dsl.line_uptime_s,
- info.dsl.atuc_vendor_id,
- info.dsl.power_mode_s
- );
-
- dsl_s.innerHTML = String.format('<small>%s</small>', s);
- dsl_i.innerHTML = String.format(
- '<img src="<%=resource%>/icons/ethernet.png" />' +
- '<br /><small>DSL</small>'
- );
+ var ds = document.getElementById('dsl_status_table');
+
+ while (ds.lastElementChild)
+ ds.removeChild(ds.lastElementChild);
+
+ ds.appendChild(renderBox(
+ '<%:DSL Status%>',
+ (info.dsl.line_state === 'UP'), [ ],
+ '<%:Line State%>', '%s [0x%x]'.format(info.dsl.line_state, info.dsl.line_state_detail),
+ '<%:Line Mode%>', info.dsl.line_mode_s || '-',
+ '<%:Line Uptime%>', info.dsl.line_uptime_s || '-',
+ '<%:Annex%>', info.dsl.annex_s || '-',
+ '<%:Profile%>', info.dsl.profile_s || '-',
+ '<%:Data Rate%>', '%s/s / %s/s'.format(info.dsl.data_rate_down_s, info.dsl.data_rate_up_s),
+ '<%:Max. Attainable Data Rate (ATTNDR)%>', '%s/s / %s/s'.format(info.dsl.max_data_rate_down_s, info.dsl.max_data_rate_up_s),
+ '<%:Latency%>', '%s / %s'.format(info.dsl.latency_num_down, info.dsl.latency_num_up),
+ '<%:Line Attenuation (LATN)%>', '%d dB / %d dB'.format(info.dsl.line_attenuation_down, info.dsl.line_attenuation_up),
+ '<%:Signal Attenuation (SATN)%>', '%d dB / %d dB'.format(info.dsl.signal_attenuation_down, info.dsl.signal_attenuation_up),
+ '<%:Noise Margin (SNR)%>', '%d dB / %d dB'.format(info.dsl.noise_margin_down, info.dsl.noise_margin_up),
+ '<%:Aggregate Transmit Power(ACTATP)%>', '%d dB / %d dB'.format(info.dsl.actatp_down, info.dsl.actatp_up),
+ '<%:Forward Error Correction Seconds (FECS)%>', '%d / %d'.format(info.dsl.errors_fec_near, info.dsl.errors_fec_far),
+ '<%:Errored seconds (ES)%>', '%d / %d'.format(info.dsl.errors_es_near, info.dsl.errors_es_far),
+ '<%:Severely Errored Seconds (SES)%>', '%d / %d'.format(info.dsl.errors_ses_near, info.dsl.errors_ses_far),
+ '<%:Loss of Signal Seconds (LOSS)%>', '%d / %d'.format(info.dsl.errors_loss_near, info.dsl.errors_loss_far),
+ '<%:Unavailable Seconds (UAS)%>', '%d / %d'.format(info.dsl.errors_uas_near, info.dsl.errors_uas_far),
+ '<%:Header Error Code Errors (HEC)%>', '%d / %d'.format(info.dsl.errors_hec_near, info.dsl.errors_hec_far),
+ '<%:Non Pre-emtive CRC errors (CRC_P)%>', '%d / %d'.format(info.dsl.errors_crc_p_near, info.dsl.errors_crc_p_far),
+ '<%:Pre-emtive CRC errors (CRCP_P)%>', '%d / %d'.format(info.dsl.errors_crcp_p_near, info.dsl.errors_crcp_p_far),
+ '<%:ATU-C System Vendor ID%>', info.dsl.atuc_vendor_id,
+ '<%:Power Management Mode%>', info.dsl.power_mode_s));
<% end %>
<% if has_wifi then %>
@@ -452,18 +425,8 @@
<div class="cbi-section">
<h3><%:DSL%></h3>
- <div class="table" width="100%">
- <div class="tr">
- <div class="td left" width="33%" style="vertical-align:top"><%:DSL Status%></div>
- <div class="td">
- <div class="table">
- <div class="tr">
- <div class="td" id="dsl_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></div>
- <div class="td left" id="dsl_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></div>
- </div>
- </div>
- </div>
- </div>
+ <div id="dsl_status_table" class="network-status-table">
+ <p><em><%:Collecting data...%></em></p>
</div>
</div>
<% end %>
diff --git a/themes/luci-theme-bootstrap/htdocs/luci-static/bootstrap/cascade.css b/themes/luci-theme-bootstrap/htdocs/luci-static/bootstrap/cascade.css
index a85d95a95f..0c158961d2 100644
--- a/themes/luci-theme-bootstrap/htdocs/luci-static/bootstrap/cascade.css
+++ b/themes/luci-theme-bootstrap/htdocs/luci-static/bootstrap/cascade.css
@@ -1894,6 +1894,11 @@ table table td,
margin: -.125em;
}
+#dsl_status_table .ifacebox-body > span > strong {
+ display: inline-block;
+ min-width: 35%;
+}
+
.ifacebadge.large,
.network-status-table .ifacebox-body .ifacebadge {
display: inline-flex;
diff --git a/themes/luci-theme-openwrt/htdocs/luci-static/openwrt.org/cascade.css b/themes/luci-theme-openwrt/htdocs/luci-static/openwrt.org/cascade.css
index 4d3333739c..197166b73a 100644
--- a/themes/luci-theme-openwrt/htdocs/luci-static/openwrt.org/cascade.css
+++ b/themes/luci-theme-openwrt/htdocs/luci-static/openwrt.org/cascade.css
@@ -1347,6 +1347,11 @@ select + .cbi-button {
margin: .5em 0 0 0;
}
+#dsl_status_table .ifacebox-body > span > strong {
+ display: inline-block;
+ min-width: 35%;
+}
+
.zonebadge {
padding: 2px;
@@ -1646,6 +1651,10 @@ select + .cbi-button {
.hide-xs {
display: none;
}
+
+ #dsl_status_table .ifacebox-body > span > strong {
+ min-width: 50%;
+ }
}
@media screen and (max-width: 480px) {
@@ -1757,4 +1766,10 @@ select + .cbi-button {
#cbi-network-switch_vlan .td.cbi-section-actions {
flex-basis: 100%;
}
+
+ #dsl_status_table .ifacebox-body > span > strong {
+ display: block;
+ width: 100%;
+ margin-top: .5em;
+ }
}