diff options
author | Dirk Brenken <dev@brenken.org> | 2019-01-14 20:24:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-14 20:24:50 +0100 |
commit | c5c0eaab6771a6ad6568a76aa990510d137be5cf (patch) | |
tree | 72d28e6b1884efde995eebd4044a5a13276326a5 /applications/luci-app-adblock/luasrc/controller/adblock.lua | |
parent | 80ac438857ae713c6f58db64b91b196e9df5f31a (diff) | |
parent | f6ff32c40d51113dfb55b6589562cc452f6dbc30 (diff) |
Merge pull request #2456 from dibdot/adblock
luci-app-adblock: sync with release 3.6.3
Diffstat (limited to 'applications/luci-app-adblock/luasrc/controller/adblock.lua')
-rw-r--r-- | applications/luci-app-adblock/luasrc/controller/adblock.lua | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/applications/luci-app-adblock/luasrc/controller/adblock.lua b/applications/luci-app-adblock/luasrc/controller/adblock.lua index e5061bc9d9..4641ac93bb 100644 --- a/applications/luci-app-adblock/luasrc/controller/adblock.lua +++ b/applications/luci-app-adblock/luasrc/controller/adblock.lua @@ -1,4 +1,4 @@ --- Copyright 2017-2018 Dirk Brenken (dev@brenken.org) +-- Copyright 2017-2019 Dirk Brenken (dev@brenken.org) -- This is free software, licensed under the Apache License, Version 2.0 module("luci.controller.adblock", package.seeall) @@ -31,7 +31,20 @@ function index() entry({"admin", "services", "adblock", "action"}, call("adb_action"), nil).leaf = true end -function adb_action(name, domain) +function adb_action(name, ...) + local domain = select(1, ...) or "" + local search = select(2, ...) or "+" + local count = select(3, ...) or "50" + local filter = select(4, ...) or "false" + local print = select(5, ...) or "false" + + local report_params = { + search, + count, + filter, + print + } + if name == "do_suspend" then luci.sys.call("/etc/init.d/adblock suspend >/dev/null 2>&1") elseif name == "do_resume" then @@ -45,11 +58,17 @@ function adb_action(name, domain) until nixio.fs.readfile(pid_file) == "" end elseif name == "do_report" then - luci.sys.call("/etc/init.d/adblock report false >/dev/null 2>&1") + luci.sys.call("/etc/init.d/adblock report " ..table.concat(report_params, " ").. " >/dev/null 2>&1") local rep_dir = uci:get("adblock", "extra", "adb_repdir") or "/tmp" repeat nixio.nanosleep(1) until not nixio.fs.access(rep_dir.. "/adb_report.raw") + elseif name == "do_filter" then + luci.sys.call("/etc/init.d/adblock report " ..table.concat(report_params, " ").. " >/dev/null 2>&1") + local rep_dir = uci:get("adblock", "extra", "adb_repdir") or "/tmp" + repeat + nixio.nanosleep(1) + until nixio.fs.access(rep_dir.. "/adb_report.final") elseif name == "add_blacklist" then local file = uci:get("adblock", "blacklist", "adb_src") or "/etc/adblock/adblock.blacklist" if nixio.fs.access(file) then @@ -110,7 +129,7 @@ function report_text() local content rep_dir = uci:get("adblock", "extra", "adb_repdir") or "/tmp" - rep_file = rep_dir.. "/adb_report" + rep_file = rep_dir.. "/adb_report.final" http.prepare_content("text/plain") if nixio.fs.access(rep_file) then |