summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-adblock/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-adblock/luasrc')
-rw-r--r--applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua77
1 files changed, 53 insertions, 24 deletions
diff --git a/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua b/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua
index f71fb7ba4d..68f9c8897e 100644
--- a/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua
+++ b/applications/luci-app-adblock/luasrc/model/cbi/adblock/overview_tab.lua
@@ -6,9 +6,25 @@ local uci = require("uci")
local sys = require("luci.sys")
local json = require("luci.jsonc")
local adbinput = uci.get("adblock", "global", "adb_rtfile") or "/tmp/adb_runtime.json"
+local dnspath = uci.get("adblock", "global", "adb_dnsdir") or ""
local parse = json.parse(fs.readfile(adbinput) or "")
-local dnsFile1 = sys.exec("find '/tmp/dnsmasq.d/.adb_hidden' -maxdepth 1 -type f -name 'adb_list*' -print 2>/dev/null")
-local dnsFile2 = sys.exec("find '/var/lib/unbound/.adb_hidden' -maxdepth 1 -type f -name 'adb_list*' -print 2>/dev/null")
+if parse ~= nil then
+ version = parse.data.adblock_version
+ domains = parse.data.blocked_domains
+ fetch = parse.data.fetch_info
+ backend = parse.data.dns_backend
+ rundate = parse.data.last_rundate
+ if dnspath == "" then
+ if backend == "dnsmasq" then
+ dnspath = "/tmp/dnsmasq.d"
+ elseif backend == "unbound" then
+ dnspath = "/var/lib/unbound"
+ elseif backend == "named" then
+ dnspath = "/var/lib/bind"
+ end
+ end
+end
+local dnsfile = dnspath .. "/.adb_hidden/adb_list.overall"
m = Map("adblock", translate("Adblock"),
translate("Configuration of the adblock package to block ad/abuse domains by using DNS. ")
@@ -17,7 +33,13 @@ m = Map("adblock", translate("Adblock"),
.. "see online documentation</a>", "https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md"))
function m.on_after_commit(self)
- luci.sys.call("/etc/init.d/adblock reload >/dev/null 2>&1")
+ function e3.validate(self, value)
+ if value == "0" then
+ luci.sys.call("/etc/init.d/adblock reload >/dev/null 2>&1")
+ else
+ luci.sys.call("/etc/init.d/adblock start >/dev/null 2>&1")
+ end
+ end
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "adblock"))
end
@@ -30,7 +52,7 @@ o1.default = o1.enabled
o1.rmempty = false
btn = s:option(Button, "", translate("Suspend / Resume adblock"))
-if dnsFile1 ~= "" or dnsFile2 ~= "" then
+if parse ~= nil and nixio.fs.access(dnsfile) then
btn.inputtitle = translate("Resume adblock")
btn.inputstyle = "apply"
btn.disabled = false
@@ -72,52 +94,53 @@ dv1 = s:option(DummyValue, "status", translate("Status"))
dv1.template = "adblock/runtime"
if parse == nil then
dv1.value = translate("n/a")
-elseif parse.data.blocked_domains == "0" then
+elseif domains == "0" then
dv1.value = translate("no domains blocked")
-elseif dnsFile1 ~= "" or dnsFile2 ~= "" then
+elseif nixio.fs.access(dnsfile) then
dv1.value = translate("suspended")
else
dv1.value = translate("active")
end
+
dv2 = s:option(DummyValue, "adblock_version", translate("Adblock version"))
dv2.template = "adblock/runtime"
-if parse ~= nil then
- dv2.value = parse.data.adblock_version or translate("n/a")
-else
+if parse == nil then
dv2.value = translate("n/a")
+else
+ dv2.value = version
end
dv3 = s:option(DummyValue, "fetch_info", translate("Download Utility (SSL Library)"),
translate("For SSL protected blocklist sources you need a suitable SSL library, e.g. 'libustream-ssl' or the wget 'built-in'."))
dv3.template = "adblock/runtime"
-if parse ~= nil then
- dv3.value = parse.data.fetch_info or translate("n/a")
-else
+if parse == nil then
dv3.value = translate("n/a")
+else
+ dv3.value = fetch
end
dv4 = s:option(DummyValue, "dns_backend", translate("DNS backend"))
dv4.template = "adblock/runtime"
-if parse ~= nil then
- dv4.value = parse.data.dns_backend or translate("n/a")
-else
+if parse == nil then
dv4.value = translate("n/a")
+else
+ dv4.value = backend
end
dv5 = s:option(DummyValue, "blocked_domains", translate("Blocked domains (overall)"))
dv5.template = "adblock/runtime"
-if parse ~= nil then
- dv5.value = parse.data.blocked_domains or translate("n/a")
-else
+if parse == nil then
dv5.value = translate("n/a")
+else
+ dv5.value = domains
end
dv6 = s:option(DummyValue, "last_rundate", translate("Last rundate"))
dv6.template = "adblock/runtime"
-if parse ~= nil then
- dv6.value = parse.data.last_rundate or translate("n/a")
-else
+if parse == nil then
dv6.value = translate("n/a")
+else
+ dv6.value = rundate
end
-- Blocklist table
@@ -157,12 +180,18 @@ e2 = e:option(Flag, "adb_forcesrt", translate("Force Overall Sort"),
e2.default = e2.disabled
e2.rmempty = false
-e3 = e:option(Flag, "adb_backup", translate("Enable blocklist backup"))
+e3 = e:option(Flag, "adb_manmode", translate("Manual mode"),
+ translate("Do not automatically update blocklists during startup, use blocklist backups instead."))
e3.default = e3.disabled
e3.rmempty = false
-e4 = e:option(Value, "adb_backupdir", translate("Backup directory"))
-e4.datatype = "directory"
+e4 = e:option(Flag, "adb_backup", translate("Enable blocklist backup"),
+ translate("Create compressed blocklist backups, they will be used in case of download errors or during startup in manual mode."))
+e4.default = e4.disabled
e4.rmempty = false
+e5 = e:option(Value, "adb_backupdir", translate("Backup directory"))
+e5.datatype = "directory"
+e5.rmempty = false
+
return m