From 0b895b17940089f854221b340fafae83bcbb2a99 Mon Sep 17 00:00:00 2001 From: Stan Grishin Date: Fri, 4 Nov 2022 00:10:03 +0000 Subject: [PATCH] luci-app-simple-adblock: convert to js Thanks @dibdot, @jow-! Signed-off-by: Stan Grishin Update applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js Co-authored-by: Vasili Sviridov Signed-off-by: Stan Grishin Thanks @dibdot, @jow-, @vsviridov! * this includes changes made during review Co-authored-by: Vasili Sviridov Signed-off-by: Stan Grishin --- applications/luci-app-simple-adblock/Makefile | 6 +- .../resources/simple-adblock/status.js | 305 ++++++++++++++ .../resources/view/simple-adblock/overview.js | 161 ++++++++ .../luasrc/controller/simple-adblock.lua | 30 -- .../luasrc/model/cbi/simple-adblock.lua | 390 ------------------ .../luasrc/view/simple-adblock/buttons.htm | 87 ---- .../luasrc/view/simple-adblock/css.htm | 9 - .../luasrc/view/simple-adblock/error.htm | 13 - .../luasrc/view/simple-adblock/js.htm | 59 --- .../luasrc/view/simple-adblock/status.htm | 12 - .../po/templates/simple-adblock.pot | 354 ++++++++-------- .../etc/uci-defaults/40_luci-simple-adblock | 2 +- .../root/usr/libexec/rpcd/luci.simple-adblock | 312 ++++++++++++++ .../luci/menu.d/luci-app-simple-adblock.json | 13 +- .../rpcd/acl.d/luci-app-simple-adblock.json | 40 +- 15 files changed, 985 insertions(+), 808 deletions(-) create mode 100644 applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js create mode 100644 applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js delete mode 100644 applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua delete mode 100644 applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua delete mode 100644 applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm delete mode 100644 applications/luci-app-simple-adblock/luasrc/view/simple-adblock/css.htm delete mode 100644 applications/luci-app-simple-adblock/luasrc/view/simple-adblock/error.htm delete mode 100644 applications/luci-app-simple-adblock/luasrc/view/simple-adblock/js.htm delete mode 100644 applications/luci-app-simple-adblock/luasrc/view/simple-adblock/status.htm create mode 100755 applications/luci-app-simple-adblock/root/usr/libexec/rpcd/luci.simple-adblock diff --git a/applications/luci-app-simple-adblock/Makefile b/applications/luci-app-simple-adblock/Makefile index 93779c2fec..4f1309a2d0 100644 --- a/applications/luci-app-simple-adblock/Makefile +++ b/applications/luci-app-simple-adblock/Makefile @@ -1,15 +1,15 @@ -# Copyright 2017-2018 Stan Grishin (stangri@melmac.ca) +# Copyright 2017-2022 Stan Grishin (stangri@melmac.ca) # This is free software, licensed under the GNU General Public License v3. include $(TOPDIR)/rules.mk PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Stan Grishin -PKG_VERSION:=1.9.2-3 +PKG_VERSION:=1.9.2-4 LUCI_TITLE:=Simple Adblock Web UI LUCI_DESCRIPTION:=Provides Web UI for simple-adblock service. -LUCI_DEPENDS:=+luci-compat +luci-mod-admin-full +simple-adblock +LUCI_DEPENDS:=+luci-mod-admin-full +simple-adblock +jsonfilter LUCI_PKGARCH:=all include ../../luci.mk diff --git a/applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js b/applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js new file mode 100644 index 0000000000..bde2e34c5b --- /dev/null +++ b/applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js @@ -0,0 +1,305 @@ +// Copyright 2022 Stan Grishin +// This code wouldn't have been possible without help from [@vsviridov](https://github.com/vsviridov) + +"require ui"; +"require rpc"; +"require form"; +"require baseclass"; + +var pkg = { + get Name() { return 'simple-adblock'; }, + get URL() { return 'https://docs.openwrt.melmac.net/' + pkg.Name + '/'; }, +}; + +var getInitList = rpc.declare({ + object: "luci." + pkg.Name, + method: "getInitList", + params: ["name"], +}); + +var getInitStatus = rpc.declare({ + object: "luci." + pkg.Name, + method: "getInitStatus", + params: ["name"], +}); + +var getPlatformSupport = rpc.declare({ + object: "luci." + pkg.Name, + method: "getPlatformSupport", + params: ["name"], +}); + +var _setInitAction = rpc.declare({ + object: "luci." + pkg.Name, + method: "setInitAction", + params: ["name", "action"], + expect: { result: false }, +}); + +var RPC = { + listeners: [], + on: function on(event, callback) { + var pair = { event: event, callback: callback } + this.listeners.push(pair); + return function unsubscribe() { + this.listeners = this.listeners.filter(function (listener) { + return listener !== pair; + }); + }.bind(this); + }, + emit: function emit(event, data) { + this.listeners.forEach(function (listener) { + if (listener.event === event) { + listener.callback(data); + } + }); + }, + getInitList: function getInitList(name) { + getInitList(name).then(function (result) { + this.emit('getInitList', result); + }.bind(this)); + }, + getInitStatus: function getInitStatus(name) { + getInitStatus(name).then(function (result) { + this.emit('getInitStatus', result); + }.bind(this)); + }, + getPlatformSupport: function getPlatformSupport(name) { + getPlatformSupport(name).then(function (result) { + this.emit('getPlatformSupport', result); + }.bind(this)); + }, + setInitAction: function setInitAction(name, action) { + _setInitAction(name, action).then(function (result) { + this.emit('setInitAction', result); + }.bind(this)); + }, +} + +var status = baseclass.extend({ + render: function () { + return Promise.all([ + L.resolveDefault(getInitStatus(), {}), + ]).then(function (data) { + var replyStatus = data[0]; + var text =""; + var status = replyStatus[pkg.Name]; + var outputFile = status.outputFile; + var outputCache = status.outputCache; + var statusTable = { + statusNoInstall: _("%s is not installed or not found").format(pkg.Name), + statusStopped: _("Stopped"), + statusStarting: _("Starting"), + statusRestarting: _("Restarting"), + statusForceReloading: _("Force Reloading"), + statusDownloading: _("Downloading"), + statusError: _("Error"), + statusWarning: _("Warning"), + statusFail: _("Fail"), + statusSuccess: _("Active") + }; + + var header = E('h2', {}, _("Simple AdBlock - Status")) + var statusTitle = E('label', { class: 'cbi-value-title' }, _("Service Status")); + if (status.version) { + text += _("Version: %s").format(status.version) + " - "; + switch (status.status) { + case 'statusSuccess': + text += statusTable[status.status] + "."; + text += "
" + _("Blocking %s domains (with %s).").format(status.entries, status.dns); + if (status.outputGzipExists) { + text += "
" + _("Compressed cache file created."); + } + if (status.force_dns_active) { + text += "
" + _("Force DNS ports:"); + status.force_dns_ports.forEach(element => { + text += " " + element; + }); + text += "."; + } + break; + case 'statusStopped': + if (status.enabled) { + text += statusTable[status.status] + "."; + } + else { + text += statusTable[status.status] + _("disabled") + "." + } + if (status.outputCacheExists) { + text += "
" + _("Cache file found."); + } + else if (status.outputGzipExists) { + text += "
" + _("Compressed cache file found."); + } + break; + case 'statusRestarting': + case 'statusForceReloading': + case 'statusDownloading': + text += statusTable[status.status] + "..."; + break; + default: + text += statusTable[status.status] + "."; + break; + } + } + else { + text = _("Not installed or not found"); + } + var statusText = E('div', {}, text); + var statusField = E('div', { class: 'cbi-value-field' }, statusText); + var statusDiv = E('div', { class: 'cbi-value' }, [statusTitle, statusField]); + + var warningsDiv = []; + if (status.warnings) { + var warningsTitle = E('label', { class: 'cbi-value-title' }, _("Service Warnings")); + var warningsText = E('div', {}, status.warnings); + var warningsField = E('div', { class: 'cbi-value-field' }, warningsText); + warningsDiv = E('div', { class: 'cbi-value' }, [warningsTitle, warningsField]); + } + + var errorsDiv = []; + if ((status.errors).length) { + var errorTable = { + errorOutputFileCreate: _("failed to create '%s' file").format(outputFile), + errorFailDNSReload: _("failed to restart/reload DNS resolver"), + errorSharedMemory: _("failed to access shared memory"), + errorSorting: _("failed to sort data file"), + errorOptimization: _("failed to optimize data file"), + errorAllowListProcessing: _("failed to process allow-list"), + errorDataFileFormatting: _("failed to format data file"), + errorMovingDataFile: _("failed to move temporary data file to '%s'").format(outputFile), + errorCreatingCompressedCache: _("failed to create compressed cache"), + errorRemovingTempFiles: _("failed to remove temporary files"), + errorRestoreCompressedCache: _("failed to unpack compressed cache"), + errorRestoreCache: _("failed to move '%s' to '%s'").format(outputCache, outputFile), + errorOhSnap: _("failed to create block-list or restart DNS resolver"), + errorStopping: _("failed to stop %s").format(pkg.Name), + errorDNSReload: _("failed to reload/restart DNS resolver"), + errorDownloadingConfigUpdate: _("failed to download Config Update file"), + errorDownloadingList: _("failed to download"), + errorParsingConfigUpdate: _("failed to parse Config Update file"), + errorParsingList: _("failed to parse"), + errorNoSSLSupport: _("no HTTPS/SSL support on device"), + errorCreatingDirectory: _("failed to create output/cache/gzip file directory") + } + var errorsTitle = E('label', { class: 'cbi-value-title' }, _("Service Errors")); + var text = ""; + (status.errors).forEach(element => { + text += errorTable[element] + ".
"; + }); + var errorsText = E('div', {}, text); + var errorsField = E('div', { class: 'cbi-value-field' }, errorsText); + errorsDiv = E('div', { class: 'cbi-value' }, [errorsTitle, errorsField]); + } + + var btn_gap = E('span', {}, '  '); + var btn_gap_long = E('span', {}, '        '); + + var btn_start = E('button', { + 'class': 'btn cbi-button cbi-button-apply', + disabled: true, + click: function (ev) { + ui.showModal(null, [ + E('p', { 'class': 'spinning' }, _('Starting %s service').format(pkg.Name)) + ]); + return RPC.setInitAction(pkg.Name, 'start'); + } + }, _('Start')); + + var btn_action = E('button', { + 'class': 'btn cbi-button cbi-button-apply', + disabled: true, + click: function (ev) { + ui.showModal(null, [ + E('p', { 'class': 'spinning' }, _('Force re-downloading %s block lists').format(pkg.Name)) + ]); + return RPC.setInitAction(pkg.Name, 'dl'); + } + }, _('Force Re-Download')); + + var btn_stop = E('button', { + 'class': 'btn cbi-button cbi-button-reset', + disabled: true, + click: function (ev) { + ui.showModal(null, [ + E('p', { 'class': 'spinning' }, _('Stopping %s service').format(pkg.Name)) + ]); + return RPC.setInitAction(pkg.Name, 'stop'); + } + }, _('Stop')); + + var btn_enable = E('button', { + 'class': 'btn cbi-button cbi-button-apply', + disabled: true, + click: function (ev) { + ui.showModal(null, [ + E('p', { 'class': 'spinning' }, _('Enabling %s service').format(pkg.Name)) + ]); + return RPC.setInitAction(pkg.Name, 'enable'); + } + }, _('Enable')); + + var btn_disable = E('button', { + 'class': 'btn cbi-button cbi-button-reset', + disabled: true, + click: function (ev) { + ui.showModal(null, [ + E('p', { 'class': 'spinning' }, _('Disabling %s service').format(pkg.Name)) + ]); + return RPC.setInitAction(pkg.Name, 'disable'); + } + }, _('Disable')); + + if (status.enabled) { + btn_enable.disabled = true; + btn_disable.disabled = false; + switch (status.status) { + case 'statusSuccess': + btn_start.disabled = true; + btn_action.disabled = false; + btn_stop.disabled = false; + break; + case 'statusStopped': + btn_start.disabled = false; + btn_action.disabled = true; + btn_stop.disabled = true; + break; + default: + btn_start.disabled = true; + btn_action.disabled = true; + btn_stop.disabled = true; + btn_enable.disabled = true; + btn_disable.disabled = true; + break; + } + } + else { + btn_start.disabled = true; + btn_action.disabled = true; + btn_stop.disabled = true; + btn_enable.disabled = false; + btn_disable.disabled = true; + } + + var buttonsDiv = []; + var buttonsTitle = E('label', { class: 'cbi-value-title' }, _("Service Control")) + var buttonsText = E('div', {}, [btn_start, btn_gap, btn_action, btn_gap, btn_stop, btn_gap_long, btn_enable, btn_gap, btn_disable]); + var buttonsField = E('div', { class: 'cbi-value-field' }, buttonsText); + if (status.version) { + buttonsDiv = E('div', { class: 'cbi-value' }, [buttonsTitle, buttonsField]); + } + + return E('div', {}, [header, statusDiv, warningsDiv, errorsDiv, buttonsDiv]); + }); + }, +}); + +RPC.on('setInitAction', function (reply) { + ui.hideModal(); + location.reload(); +}); + +return L.Class.extend({ + status: status, + getPlatformSupport: getPlatformSupport +}); diff --git a/applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js b/applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js new file mode 100644 index 0000000000..e9334654a1 --- /dev/null +++ b/applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js @@ -0,0 +1,161 @@ +// Copyright 2022 Stan Grishin +// This code wouldn't have been possible without help from [@vsviridov](https://github.com/vsviridov) + +'use strict'; +'require form'; +'require uci'; +'require view'; +'require simple-adblock.status as adb'; + +var pkg = { + get Name() { return 'simple-adblock'; }, + get URL() { return 'https://docs.openwrt.melmac.net/' + pkg.Name + '/'; } +}; + +return view.extend({ + load: function () { + return Promise.all([ + uci.load(pkg.Name) + ]); + }, + + render: function () { + return Promise.all([ + L.resolveDefault(adb.getPlatformSupport(), {}), + ]).then(function (data) { + var replyPlatform = data[0]; + var status, m, s, o; + + status = new adb.status(); + m = new form.Map(pkg.Name, _("Simple AdBlock - Configuration")); + s = m.section(form.NamedSection, 'config', pkg.Name); + s.tab("tab_basic", _("Basic Configuration")); + s.tab("tab_advanced", _("Advanced Configuration")); + + o = s.taboption("tab_basic", form.ListValue, "config_update_enabled", _("Automatic Config Update"), + _("Perform config update before downloading the block/allow-lists.")); + o.value("0", _("Disable")); + o.value("1", _("Enable")); + o.default = ("0", _("Disable")); + + o = s.taboption("tab_basic", form.ListValue, "verbosity", _("Output Verbosity Setting"), + _("Controls system log and console output verbosity.")); + o.value("0", _("Suppress output")); + o.value("1", _("Some output")); + o.value("2", _("Verbose output")); + o.default = ("2", _("Verbose output")); + + o = s.taboption("tab_basic", form.ListValue, "force_dns", _("Force Router DNS"), + _("Forces Router DNS use on local devices, also known as DNS Hijacking.")); + o.value("0", _("Let local devices use their own DNS servers if set")); + o.value("1", _("Force Router DNS server to all local devices")); + o.default = ("1", _("Force Router DNS server to all local devices")); + + + if ((replyPlatform[pkg.Name].leds).length) { + o = s.taboption("tab_basic", form.ListValue, "led", _("LED to indicate status"), + _("Pick the LED not already used in %sSystem LED Configuration%s.").format("", "")); + o.value("", _("none")); + (replyPlatform[pkg.Name].leds).forEach(element => { + o.value(element); + }); + o.rmempty = false; + } + var text = _("DNS resolution option, see the %sREADME%s for details.") + .format("", ""); + if (!(replyPlatform[pkg.Name].dnsmasq_installed)) { + text += "
" + _("Please note that %s is not supported on this system.").format("dnsmasq.addnhosts"); + text += "
" + _("Please note that %s is not supported on this system.").format("dnsmasq.conf"); + text += "
" + _("Please note that %s is not supported on this system.").format("dnsmasq.ipset"); + text += "
" + _("Please note that %s is not supported on this system.").format("dnsmasq.servers"); + } + else { + if (!(replyPlatform[pkg.Name].dnsmasq_ipset_support)) { + text += _("Please note that %s is not supported on this system.").format("dnsmasq.ipset") + "
"; + } + if (!(replyPlatform[pkg.Name].dnsmasq_nftset_support)) { + text += _("Please note that %s is not supported on this system.").format("dnsmasq.nftset") + "
"; + } + } + if (!(replyPlatform[pkg.Name].unbound_installed)) { + text = text + "
" + _("Please note that %s is not supported on this system.") + .format("unbound.adb_list"); + } + + o = s.taboption("tab_advanced", form.ListValue, "dns", _("DNS Service"), text); + if (replyPlatform[pkg.Name].dnsmasq_installed) { + o.value("dnsmasq.addnhosts", _("dnsmasq additional hosts")); + o.value("dnsmasq.conf", _("dnsmasq config")); + if (replyPlatform[pkg.Name].dnsmasq_ipset_support) { + o.value("dnsmasq.ipset", _("dnsmasq ipset")); + } + if (replyPlatform[pkg.Name].dnsmasq_nftset_support) { + o.value("dnsmasq.nftset", _("dnsmasq nft set")); + } + o.value("dnsmasq.servers", _("dnsmasq servers file")); + } + if (replyPlatform[pkg.Name].unbound_installed) { + o.value("unbound.adb_list", _("unbound adblock list")); + } + o.default = ("dnsmasq.servers", _("dnsmasq servers file")); + + o = s.taboption("tab_advanced", form.ListValue, "ipv6_enabled", _("IPv6 Support"), + _("Add IPv6 entries to block-list.")); + o.value("", _("Do not add IPv6 entries")); + o.value("1", _("Add IPv6 entries")); + o.depends('dns', 'dnsmasq.addnhosts'); + o.depends('dns', 'dnsmasq.nftset'); + o.default = ("", _("Do not add IPv6 entries")); + o.rmempty = true; + + o = s.taboption("tab_advanced", form.Value, "download_timeout", _("Download time-out (in seconds)"), + _("Stop the download if it is stalled for set number of seconds.")); + o.default = "10"; + o.datatype = "range(1,60)"; + + o = s.taboption("tab_advanced", form.Value, "curl_retry", _("Curl download retry"), + _("If curl is installed and detected, it would retry download this many times on timeout/fail.")); + o.default = "3"; + o.datatype = "range(0,30)"; + + o = s.taboption("tab_advanced", form.ListValue, "parallel_downloads", _("Simultaneous processing"), + _("Launch all lists downloads and processing simultaneously, reducing service start time.")); + o.value("0", _("Do not use simultaneous processing")); + o.value("1", _("Use simultaneous processing")); + o.default = ("1", _("Use simultaneous processing")); + + o = s.taboption("tab_advanced", form.ListValue, "compressed_cache", _("Store compressed cache file on router"), + _("Attempt to create a compressed cache of block-list in the persistent memory.")); + o.value("0", _("Do not store compressed cache")); + o.value("1", _("Store compressed cache")); + o.default = ("0", _("Do not store compressed cache")); + + o = s.taboption("tab_advanced", form.ListValue, "debug", _("Enable Debugging"), + _("Enables debug output to /tmp/simple-adblock.log.")); + o.value("0", _("Disable Debugging")); + o.value("1", _("Enable Debugging")); + o.default = ("0", _("Disable Debugging")); + + s = m.section(form.NamedSection, "config", "simple-adblock", + _("Allowed and Blocked Lists Management")); + o = s.option(form.DynamicList, "allowed_domain", _("Allowed Domains"), + _("Individual domains to be allowed.")); + o.addremove = false; + o = s.option(form.DynamicList, "allowed_domains_url", _("Allowed Domain URLs"), + _("URLs to lists of domains to be allowed.")); + o.addremove = false; + o = s.option(form.DynamicList, "blocked_domain", _("Blocked Domains"), + _("Individual domains to be blocked.")); + o.addremove = false; + o = s.option(form.DynamicList, "blocked_domains_url", _("Blocked Domain URLs"), + _("URLs to lists of domains to be blocked.")); + o.addremove = false; + o = s.option(form.DynamicList, "blocked_hosts_url", _("Blocked Hosts URLs"), + _("URLs to lists of hosts to be blocked.")); + o.addremove = false; + + return Promise.all([status.render(), m.render()]); + }) + } +}); diff --git a/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua b/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua deleted file mode 100644 index 1c56502480..0000000000 --- a/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua +++ /dev/null @@ -1,30 +0,0 @@ -module("luci.controller.simple-adblock", package.seeall) -function index() - if nixio.fs.access("/etc/config/simple-adblock") then - entry({"admin", "services", "simple-adblock"}, cbi("simple-adblock"), _("Simple AdBlock")).acl_depends = { "luci-app-simple-adblock" } - entry({"admin", "services", "simple-adblock", "action"}, call("simple_adblock_action"), nil).leaf = true - end -end - -function simple_adblock_action(name) - local packageName = "simple-adblock" - local http = require "luci.http" - local sys = require "luci.sys" - local uci = require "luci.model.uci".cursor() - local util = require "luci.util" - if name == "start" then - sys.init.start(packageName) - elseif name == "action" then - util.exec("/etc/init.d/" .. packageName .. " dl >/dev/null 2>&1") - elseif name == "stop" then - sys.init.stop(packageName) - elseif name == "enable" then - uci:set(packageName, "config", "enabled", "1") - uci:commit(packageName) - elseif name == "disable" then - uci:set(packageName, "config", "enabled", "0") - uci:commit(packageName) - end - http.prepare_content("text/plain") - http.write("0") -end diff --git a/applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua b/applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua deleted file mode 100644 index ec047420a8..0000000000 --- a/applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua +++ /dev/null @@ -1,390 +0,0 @@ --- Copyright 2016-2018 Stan Grishin --- Licensed to the public under the Apache License 2.0. - -local packageName = "simple-adblock" -local readmeURL = "https://docs.openwrt.melmac.net/" .. packageName .. "/" -local uci = require "luci.model.uci".cursor() -local util = require "luci.util" -local sys = require "luci.sys" -local jsonc = require "luci.jsonc" -local fs = require "nixio.fs" -local nutil = require "nixio.util" -local http = require "luci.http" -local dispatcher = require "luci.dispatcher" - -local jsonStatusFile = "/var/run/" .. packageName .. "/" .. packageName .. ".json" - -function getPackageVersion() - local opkgFile = "/usr/lib/opkg/status" - local line - local flag = false - for line in io.lines(opkgFile) do - if flag then - return line:match('[%d%.$-]+') or "" - elseif line:find("Package: " .. packageName:gsub("%-", "%%%-")) then - flag = true - end - end - return "" -end - -function getFileLines(file) - local f = io.open(file) - if f then - local t = f:read("*a") - local _,n = t:gsub("\n","") - f:close() - return n - else - return "0" - end -end - -function checkDnsmasq() return fs.access("/usr/sbin/dnsmasq") end -function checkUnbound() return fs.access("/usr/sbin/unbound") end - -function checkIpset() - if fs.access("/usr/sbin/ipset") and sys.call("/usr/sbin/ipset help hash:net >/dev/null 2>&1") == 0 then - return true - else - return false - end -end - -function checkNftset() - if sys.call("command -v nft >/dev/null 2>&1") == 0 then - return true - else - return false - end -end - -function checkDnsmasqIpset() - if checkDnsmasq() then - local o = util.trim(util.exec("/usr/sbin/dnsmasq -v 2>/dev/null")) - if not o:match("no%-ipset") and o:match("ipset") and checkIpset() then - return true - else - return false - end - else - return false - end -end - -function checkDnsmasqNftset() - if checkDnsmasq() then - local o = util.trim(util.exec("/usr/sbin/dnsmasq -v 2>/dev/null")) - if not o:match("no%-nftset") and o:match("nftset") and checkNftset() then - return true - else - return false - end - else - return false - end -end - -local enabledFlag = uci:get(packageName, "config", "enabled") -local command, outputFile, outputCache, outputGzip -local targetDNS = uci:get(packageName, "config", "dns") - -if not targetDNS or targetDNS == "" then - targetDNS = "dnsmasq.servers" -end - -if targetDNS ~= "dnsmasq.addnhosts" and targetDNS ~= "dnsmasq.conf" and - targetDNS ~= "dnsmasq.ipset" and targetDNS ~= "dnsmasq.nftset" and - targetDNS ~= "dnsmasq.servers" and targetDNS ~= "unbound.adb_list" then - targetDNS = "dnsmasq.servers" -end - -if targetDNS == "dnsmasq.addnhosts" then - outputFile="/var/run/" .. packageName .. "/dnsmasq.addnhosts" - outputCache="/var/run/" .. packageName .. "/dnsmasq.addnhosts.cache" - outputGzip="/etc/" .. packageName .. ".dnsmasq.addnhosts.gz" -elseif targetDNS == "dnsmasq.conf" then - outputFile="/tmp/dnsmasq.d/" .. packageName - outputCache="/var/run/" .. packageName .. "/dnsmasq.conf.cache" - outputGzip="/etc/" .. packageName .. ".dnsmasq.conf.gz" -elseif targetDNS == "dnsmasq.ipset" then - outputFile="/tmp/dnsmasq.d/" .. packageName .. ".ipset" - outputCache="/var/run/" .. packageName .. "/dnsmasq.ipset.cache" - outputGzip="/etc/" .. packageName .. ".dnsmasq.ipset.gz" -elseif targetDNS == "dnsmasq.nftset" then - outputFile="/tmp/dnsmasq.d/" .. packageName .. ".nftset" - outputCache="/var/run/" .. packageName .. "/dnsmasq.nftset.cache" - outputGzip="/etc/" .. packageName .. ".dnsmasq.nftset.gz" -elseif targetDNS == "dnsmasq.servers" then - outputFile="/var/run/" .. packageName .. "/dnsmasq.servers" - outputCache="/var/run/" .. packageName .. "/dnsmasq.servers.cache" - outputGzip="/etc/" .. packageName .. ".dnsmasq.servers.gz" -elseif targetDNS == "unbound.adb_list" then - outputFile="/var/lib/unbound/adb_list." .. packageName - outputCache="/var/run/" .. packageName .. "/unbound.cache" - outputGzip="/etc/" .. packageName .. ".unbound.gz" -end - -local packageVersion = getPackageVersion() -local tmpfs, tmpfsMessage, tmpfsError, tmpfsStats, tmpfsStatus - -if packageVersion == "" then - tmpfsStatus = "statusNoInstall" -else - tmpfsStatus = "statusStopped" -end - -if fs.access(jsonStatusFile) then - local f = io.open(jsonStatusFile) - local s = f:read("*a") - f:close() - tmpfs = jsonc.parse(s) -end - -if tmpfs and tmpfs['data'] then - if tmpfs['data']['status'] and tmpfs['data']['status'] ~= "" then - tmpfsStatus = tmpfs['data']['status'] - end - if tmpfs['data']['message'] and tmpfs['data']['message'] ~= "" then - tmpfsMessage = tmpfs['data']['message'] - end - if tmpfs['data']['error'] and tmpfs['data']['error'] ~= "" then - tmpfsError = tmpfs['data']['error'] - end - if tmpfs['data']['stats'] and tmpfs['data']['stats'] ~= "" then - tmpfsStats = tmpfs['data']['stats'] - end -end - -local statusTable = {} -local errorTable = {} -statusTable["statusNoInstall"] = translatef("%s is not installed or not found", packageName) -statusTable["statusStopped"] = translate("Stopped") -statusTable["statusStarting"] = translate("Starting") -statusTable["statusRestarting"] = translate("Restarting") -statusTable["statusForceReloading"] = translate("Force Reloading") -statusTable["statusDownloading"] = translate("Downloading") -statusTable["statusError"] = translate("Error") -statusTable["statusWarning"] = translate("Warning") -statusTable["statusFail"] = translate("Fail") -statusTable["statusSuccess"] = translate("Success") -errorTable["errorOutputFileCreate"] = translatef("failed to create '%s' file", outputFile) -errorTable["errorFailDNSReload"] = translate("failed to restart/reload DNS resolver") -errorTable["errorSharedMemory"] = translate("failed to access shared memory") -errorTable["errorSorting"] = translate("failed to sort data file") -errorTable["errorOptimization"] = translate("failed to optimize data file") -errorTable["errorAllowListProcessing"] = translate("failed to process allow-list") -errorTable["errorDataFileFormatting"] = translate("failed to format data file") -errorTable["errorMovingDataFile"] = translatef("failed to move temporary data file to '%s'", outputFile) -errorTable["errorCreatingCompressedCache"] = translate("failed to create compressed cache") -errorTable["errorRemovingTempFiles"] = translate("failed to remove temporary files") -errorTable["errorRestoreCompressedCache"] = translate("failed to unpack compressed cache") -errorTable["errorRestoreCache"] = translatef("failed to move '%s' to '%s'", outputCache, outputFile) -errorTable["errorOhSnap"] = translate("failed to create block-list or restart DNS resolver") -errorTable["errorStopping"] = translatef("failed to stop %s", packageName) -errorTable["errorDNSReload"] = translate("failed to reload/restart DNS resolver") -errorTable["errorDownloadingConfigUpdate"] = translate("failed to download Config Update file") -errorTable["errorDownloadingList"] = translate("failed to download") -errorTable["errorParsingConfigUpdate"] = translate("failed to parse Config Update file") -errorTable["errorParsingList"] = translate("failed to parse") -errorTable["errorNoSSLSupport"] = translate("no HTTPS/SSL support on device") -errorTable["errorCreatingDirectory"] = translate("failed to create output/cache/gzip file directory") - -m = Map("simple-adblock", translate("Simple AdBlock Settings")) -m.apply_on_parse = true -m.on_after_apply = function(self) - sys.call("/etc/init.d/simple-adblock restart") -end - -h = m:section(NamedSection, "config", "simple-adblock", translatef("Service Status [%s %s]", packageName, packageVersion)) - -if tmpfsStatus == "statusStarting" or - tmpfsStatus == "statusRestarting" or - tmpfsStatus == "statusForceReloading" or - tmpfsStatus == "statusDownloading" then - ss = h:option(DummyValue, "_dummy", translate("Service Status")) - ss.template = "simple-adblock/status" - ss.value = statusTable[tmpfsStatus] .. '...' - if tmpfsMessage then - sm = h:option(DummyValue, "_dummy", translate("Task")) - sm.template = "simple-adblock/status" - sm.value = tmpfsMessage - end -else - if tmpfsStatus == "statusStopped" then - ss = h:option(DummyValue, "_dummy", translate("Service Status")) - ss.template = "simple-adblock/status" - ss.value = statusTable[tmpfsStatus] - if fs.access(outputCache) then - sm = h:option(DummyValue, "_dummy", translate("Info")) - sm.template = "simple-adblock/status" - sm.value = translatef("Cache file containing %s domains found.", getFileLines(outputCache)) - elseif fs.access(outputGzip) then - sm = h:option(DummyValue, "_dummy", translate("Info")) - sm.template = "simple-adblock/status" - sm.value = translate("Compressed cache file found.") - end - else - ss = h:option(DummyValue, "_dummy", translate("Service Status")) - ss.template = "simple-adblock/status" - if tmpfsStatus == "statusSuccess" then - ss.value = translatef("Blocking %s domains (with %s).", getFileLines(outputFile), targetDNS) - else - ss.value = statusTable[tmpfsStatus] - end - if tmpfsMessage then - ms = h:option(DummyValue, "_dummy", translate("Message")) - ms.template = "simple-adblock/status" - ms.value = tmpfsMessage - end - if tmpfsError then - es = h:option(DummyValue, "_dummy", translate("Collected Errors")) - es.template = "simple-adblock/status" - es.value = "" - local err, e, url - for err in tmpfsError:gmatch("[%p%w]+") do - if err:match("|") then - e,url = err:match("(.+)|(.+)") - es.value = translatef("%s Error: %s %s", es.value, errorTable[e], url) .. ".\n" - else - es.value = translatef("%s Error: %s", es.value, errorTable[err]) .. ".\n" - end - end - end - end - if packageVersion ~= "" then - buttons = h:option(DummyValue, "_dummy", translate("Service Control")) - buttons.template = packageName .. "/buttons" - end -end - -s = m:section(NamedSection, "config", "simple-adblock", translate("Configuration")) --- General options -s:tab("basic", translate("Basic Configuration")) - -o1 = s:taboption("basic", ListValue, "config_update_enabled", translate("Automatic Config Update"), translate("Perform config update before downloading the block/allow-lists.")) -o1:value("0", translate("Disable")) -o1:value("1", translate("Enable")) -o1.default = "0" - -o2 = s:taboption("basic", ListValue, "verbosity", translate("Output Verbosity Setting"), translate("Controls system log and console output verbosity.")) -o2:value("0", translate("Suppress output")) -o2:value("1", translate("Some output")) -o2:value("2", translate("Verbose output")) -o2.default = "2" - -o3 = s:taboption("basic", ListValue, "force_dns", translate("Force Router DNS"), translate("Forces Router DNS use on local devices, also known as DNS Hijacking.")) -o3:value("0", translate("Let local devices use their own DNS servers if set")) -o3:value("1", translate("Force Router DNS server to all local devices")) -o3.default = "1" - -local sysfs_path = "/sys/class/leds/" -local leds = {} -if fs.access(sysfs_path) then - leds = nutil.consume((fs.dir(sysfs_path))) -end -if #leds ~= 0 then - o4 = s:taboption("basic", Value, "led", translate("LED to indicate status"), - translatef("Pick the LED not already used in %sSystem LED Configuration%s.", "", "")) - o4.rmempty = false - o4:value("", translate("none")) - for k, v in ipairs(leds) do - o4:value(v) - end -end - -s:tab("advanced", translate("Advanced Configuration")) - -local dns_descr = translatef("Pick the DNS resolution option to create the adblock list for, see the %sREADME%s for details.", "", "") - -if not checkDnsmasq() then - dns_descr = dns_descr .. "
" .. translatef("Please note that %s is not supported on this system.", "dnsmasq.addnhosts") - dns_descr = dns_descr .. "
" .. translatef("Please note that %s is not supported on this system.", "dnsmasq.conf") - dns_descr = dns_descr .. "
" .. translatef("Please note that %s is not supported on this system.", "dnsmasq.ipset") - dns_descr = dns_descr .. "
" .. translatef("Please note that %s is not supported on this system.", "dnsmasq.servers") -else - if not checkDnsmasqIpset() then - dns_descr = dns_descr .. "
" .. translatef("Please note that %s is not supported on this system.", "dnsmasq.ipset") - end - if not checkDnsmasqNftset() then - dns_descr = dns_descr .. "
" .. translatef("Please note that %s is not supported on this system.", "dnsmasq.nftset") - end -end -if not checkUnbound() then - dns_descr = dns_descr .. "
" .. translatef("Please note that %s is not supported on this system.", "unbound.adb_list") -end - -dns = s:taboption("advanced", ListValue, "dns", translate("DNS Service"), dns_descr) -if checkDnsmasq() then - dns:value("dnsmasq.addnhosts", translate("DNSMASQ Additional Hosts")) - dns:value("dnsmasq.conf", translate("DNSMASQ Config")) - if checkDnsmasqIpset() then - dns:value("dnsmasq.ipset", translate("DNSMASQ Ipset")) - end - if checkDnsmasqNftset() then - dns:value("dnsmasq.nftset", translate("DNSMASQ Nft Set")) - end - dns:value("dnsmasq.servers", translate("DNSMASQ Servers File")) -end -if checkUnbound() then - dns:value("unbound.adb_list", translate("Unbound AdBlock List")) -end -dns.default = "dnsmasq.servers" - -ipv6 = s:taboption("advanced", ListValue, "ipv6_enabled", translate("IPv6 Support"), translate("Add IPv6 entries to block-list.")) -ipv6:value("", translate("Do not add IPv6 entries")) -ipv6:value("1", translate("Add IPv6 entries")) -ipv6:depends({dns="dnsmasq.addnhosts"}) -ipv6.default = "" -ipv6.rmempty = true - -o5 = s:taboption("advanced", Value, "boot_delay", translate("Delay (in seconds) for on-boot start"), translate("Run service after set delay on boot.")) -o5.default = 120 -o5.datatype = "range(1,600)" - -o6 = s:taboption("advanced", Value, "download_timeout", translate("Download time-out (in seconds)"), translate("Stop the download if it is stalled for set number of seconds.")) -o6.default = 10 -o6.datatype = "range(1,60)" - -o7 = s:taboption("advanced", Value, "curl_retry", translate("Curl download retry"), translate("If curl is installed and detected, it would retry download this many times on timeout/fail.")) -o7.default = 3 -o7.datatype = "range(0,30)" - -o8 = s:taboption("advanced", ListValue, "parallel_downloads", translate("Simultaneous processing"), translate("Launch all lists downloads and processing simultaneously, reducing service start time.")) -o8:value("0", translate("Do not use simultaneous processing")) -o8:value("1", translate("Use simultaneous processing")) -o8.default = "1" - -o10 = s:taboption("advanced", ListValue, "compressed_cache", translate("Store compressed cache file on router"), translate("Attempt to create a compressed cache of block-list in the persistent memory.")) -o10:value("0", translate("Do not store compressed cache")) -o10:value("1", translate("Store compressed cache")) -o10.default = "0" - -o11 = s:taboption("advanced", ListValue, "debug", translate("Enable Debugging"), translate("Enables debug output to /tmp/simple-adblock.log.")) -o11:value("0", translate("Disable Debugging")) -o11:value("1", translate("Enable Debugging")) -o11.default = "0" - - -s2 = m:section(NamedSection, "config", "simple-adblock", translate("Allowed and Blocked Lists Management")) --- Allowed Domains -d1 = s2:option(DynamicList, "allowed_domain", translate("Allowed Domains"), translate("Individual domains to be allowed.")) -d1.addremove = false - --- Allowed Domains URLs -d2 = s2:option(DynamicList, "allowed_domains_url", translate("Allowed Domain URLs"), translate("URLs to lists of domains to be allowed.")) -d2.addremove = false - --- Blocked Domains -d3 = s2:option(DynamicList, "blocked_domain", translate("Blocked Domains"), translate("Individual domains to be blocked.")) -d3.addremove = false - --- Blocked Domains URLs -d4 = s2:option(DynamicList, "blocked_domains_url", translate("Blocked Domain URLs"), translate("URLs to lists of domains to be blocked.")) -d4.addremove = false - --- Blocked Hosts URLs -d5 = s2:option(DynamicList, "blocked_hosts_url", translate("Blocked Hosts URLs"), translate("URLs to lists of hosts to be blocked.")) -d5.addremove = false - -return m diff --git a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm b/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm deleted file mode 100644 index c8d4e5e8a6..0000000000 --- a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm +++ /dev/null @@ -1,87 +0,0 @@ -<%# Copyright 2020 Stan Grishin -%> - -<%+simple-adblock/css%> -<%+simple-adblock/js%> - -<%- - local packageName = "simple-adblock" - local serviceRunning, serviceEnabled = false, false; - local tmpfs, tmpfsStatus; - local jsonStatusFile = "/var/run/" .. packageName .. "/" .. packageName .. ".json" - if nixio.fs.access(jsonStatusFile) then - tmpfs = luci.jsonc.parse(luci.util.trim(luci.sys.exec("cat " .. jsonStatusFile))) - if tmpfs and tmpfs['data'] and tmpfs['data']['status'] then - tmpfsStatus = tmpfs['data']['status'] - end - end - if tmpfsStatus == "statusStarting" or tmpfsStatus == "statusRestarting" or - tmpfsStatus == "statusForceReloading" or tmpfsStatus == "statusDownloading" or - tmpfsStatus == "statusError" or tmpfsStatus == "statusWarning" - or tmpfsStatus == "statusSuccess" then - serviceRunning = true - end - - if luci.model.uci.cursor():get(packageName, "config", "enabled") == "1" then - serviceEnabled = true - end - - if serviceEnabled then - btn_start_status = true - btn_action_status = true - btn_stop_status = true - btn_enable_status = false - btn_disable_status = true - else - btn_start_status = false - btn_action_status = false - btn_stop_status = false - btn_enable_status = true - btn_disable_status = false - end - if serviceRunning then - btn_start_status = false - btn_action_status = true - btn_stop_status = true - else - btn_action_status = false - btn_stop_status = false - end --%> - -<%+cbi/valueheader%> - - - - - - -   -   -   -   - - - - -<%+cbi/valuefooter%> - -<%-if not btn_start_status then%> - -<%-end%> -<%-if not btn_action_status then%> - -<%-end%> -<%-if not btn_stop_status then%> - -<%-end%> -<%-if not btn_enable_status then%> - -<%-end%> -<%-if not btn_disable_status then%> - -<%-end%> diff --git a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/css.htm b/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/css.htm deleted file mode 100644 index 6fb3d51d3b..0000000000 --- a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/css.htm +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/error.htm b/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/error.htm deleted file mode 100644 index 4ab2e11291..0000000000 --- a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/error.htm +++ /dev/null @@ -1,13 +0,0 @@ -<%# -Copyright 2017-2019 Stan Grishin (stangri@melmac.net) -This is free software, licensed under the Apache License, Version 2.0 --%> - -<%+cbi/valueheader%> - - - -<%+cbi/valuefooter%> diff --git a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/js.htm b/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/js.htm deleted file mode 100644 index 51198293f5..0000000000 --- a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/js.htm +++ /dev/null @@ -1,59 +0,0 @@ - \ No newline at end of file diff --git a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/status.htm b/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/status.htm deleted file mode 100644 index b02c7faa82..0000000000 --- a/applications/luci-app-simple-adblock/luasrc/view/simple-adblock/status.htm +++ /dev/null @@ -1,12 +0,0 @@ -<%# -Copyright 2017-2018 Dirk Brenken (dev@brenken.org) -This is free software, licensed under the Apache License, Version 2.0 --%> - -<%+cbi/valueheader%> - -
- <%=self:cfgvalue(section):gsub('\n', '
' )%> -
- -<%+cbi/valuefooter%> diff --git a/applications/luci-app-simple-adblock/po/templates/simple-adblock.pot b/applications/luci-app-simple-adblock/po/templates/simple-adblock.pot index 822816fd67..260c11aa26 100644 --- a/applications/luci-app-simple-adblock/po/templates/simple-adblock.pot +++ b/applications/luci-app-simple-adblock/po/templates/simple-adblock.pot @@ -1,191 +1,184 @@ msgid "" msgstr "Content-Type: text/plain; charset=UTF-8" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:250 -msgid "%s Error: %s" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:248 -msgid "%s Error: %s %s" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:90 +msgid "%s is not installed or not found" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:161 -msgid "%s is not installed or not found" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:99 +msgid "Active" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:336 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:106 msgid "Add IPv6 entries" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:334 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:104 msgid "Add IPv6 entries to block-list." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:296 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:33 msgid "Advanced Configuration" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:375 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:145 msgid "Allowed Domain URLs" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:371 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:142 msgid "Allowed Domains" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:369 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:141 msgid "Allowed and Blocked Lists Management" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:358 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:129 msgid "" "Attempt to create a compressed cache of block-list in the persistent memory." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:265 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:35 msgid "Automatic Config Update" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:263 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:32 msgid "Basic Configuration" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:383 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:151 msgid "Blocked Domain URLs" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:379 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:148 msgid "Blocked Domains" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:387 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:154 msgid "Blocked Hosts URLs" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:231 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:109 msgid "Blocking %s domains (with %s)." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:221 -msgid "Cache file containing %s domains found." +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:129 +msgid "Cache file found." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:241 -msgid "Collected Errors" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:111 +msgid "Compressed cache file created." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:225 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:132 msgid "Compressed cache file found." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:261 -msgid "Configuration" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:270 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:42 msgid "Controls system log and console output verbosity." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:349 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:117 msgid "Curl download retry" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:317 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:86 msgid "DNS Service" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:319 -msgid "DNSMASQ Additional Hosts" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:320 -msgid "DNSMASQ Config" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:322 -msgid "DNSMASQ Ipset" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:325 -msgid "DNSMASQ Nft Set" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:327 -msgid "DNSMASQ Servers File" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:341 -msgid "Delay (in seconds) for on-boot start" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:65 +msgid "DNS resolution option, see the %sREADME%s for details." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:266 -#: applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm:68 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:251 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:37 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:39 msgid "Disable" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:364 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:136 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:138 msgid "Disable Debugging" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:335 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:247 +msgid "Disabling %s service" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:105 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:109 msgid "Do not add IPv6 entries" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:359 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:130 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:132 msgid "Do not store compressed cache" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:354 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:124 msgid "Do not use simultaneous processing" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:345 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:112 msgid "Download time-out (in seconds)" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:166 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:95 msgid "Downloading" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:267 -#: applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm:65 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:240 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:38 msgid "Enable" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:363 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:365 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:134 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:137 msgid "Enable Debugging" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:363 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:135 msgid "Enables debug output to /tmp/simple-adblock.log." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:167 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:236 +msgid "Enabling %s service" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:96 msgid "Error" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:169 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:98 msgid "Fail" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm:55 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:114 +msgid "Force DNS ports:" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:218 msgid "Force Re-Download" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:165 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:94 msgid "Force Reloading" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:276 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:48 msgid "Force Router DNS" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:278 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:51 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:52 msgid "Force Router DNS server to all local devices" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:276 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:214 +msgid "Force re-downloading %s block lists" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:49 msgid "Forces Router DNS use on local devices, also known as DNS Hijacking." msgstr "" @@ -193,270 +186,287 @@ msgstr "" msgid "Grant UCI and file access for luci-app-simple-adblock" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:334 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:103 msgid "IPv6 Support" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:349 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:118 msgid "" "If curl is installed and detected, it would retry download this many times " "on timeout/fail." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:371 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:143 msgid "Individual domains to be allowed." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:379 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:149 msgid "Individual domains to be blocked." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:219 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:223 -msgid "Info" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:287 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:56 msgid "LED to indicate status" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:353 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:123 msgid "" "Launch all lists downloads and processing simultaneously, reducing service " "start time." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:277 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:50 msgid "Let local devices use their own DNS servers if set" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/view/simple-adblock/js.htm:51 -msgid "Loading" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:236 -msgid "Message" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:146 +msgid "Not installed or not found" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:270 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:41 msgid "Output Verbosity Setting" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:265 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:36 msgid "Perform config update before downloading the block/allow-lists." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:298 -msgid "" -"Pick the DNS resolution option to create the adblock list for, see the " -"%sREADME%s for details." -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:288 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:57 msgid "Pick the LED not already used in %sSystem LED Configuration%s." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:301 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:302 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:303 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:304 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:307 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:310 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:314 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:68 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:69 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:70 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:71 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:75 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:78 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:82 msgid "Please note that %s is not supported on this system." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:164 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:93 msgid "Restarting" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:341 -msgid "Run service after set delay on boot." +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:285 +msgid "Service Control" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:256 -msgid "Service Control" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:185 +msgid "Service Errors" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:205 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:215 -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:228 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:103 msgid "Service Status" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:199 -msgid "Service Status [%s %s]" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:154 +msgid "Service Warnings" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua:4 #: applications/luci-app-simple-adblock/root/usr/share/luci/menu.d/luci-app-simple-adblock.json:3 msgid "Simple AdBlock" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:193 -msgid "Simple AdBlock Settings" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:30 +msgid "Simple AdBlock - Configuration" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:102 +msgid "Simple AdBlock - Status" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:353 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:122 msgid "Simultaneous processing" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:272 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:44 msgid "Some output" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm:52 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:207 msgid "Start" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:163 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:92 msgid "Starting" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/view/simple-adblock/buttons.htm:58 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:203 +msgid "Starting %s service" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:229 msgid "Stop" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:345 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:113 msgid "Stop the download if it is stalled for set number of seconds." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:162 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:91 msgid "Stopped" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:360 -msgid "Store compressed cache" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:225 +msgid "Stopping %s service" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:358 -msgid "Store compressed cache file on router" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:131 +msgid "Store compressed cache" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:170 -msgid "Success" +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:128 +msgid "Store compressed cache file on router" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:271 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:43 msgid "Suppress output" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:209 -msgid "Task" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:375 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:146 msgid "URLs to lists of domains to be allowed." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:383 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:152 msgid "URLs to lists of domains to be blocked." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:387 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:155 msgid "URLs to lists of hosts to be blocked." msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:330 -msgid "Unbound AdBlock List" -msgstr "" - -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:355 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:125 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:126 msgid "Use simultaneous processing" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:273 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:45 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:46 msgid "Verbose output" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:168 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:105 +msgid "Version: %s" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:97 msgid "Warning" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:173 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:126 +msgid "disabled" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:88 +msgid "dnsmasq additional hosts" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:89 +msgid "dnsmasq config" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:91 +msgid "dnsmasq ipset" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:94 +msgid "dnsmasq nft set" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:96 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:101 +msgid "dnsmasq servers file" +msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:165 msgid "failed to access shared memory" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:171 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:163 msgid "failed to create '%s' file" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:183 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:175 msgid "failed to create block-list or restart DNS resolver" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:179 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:171 msgid "failed to create compressed cache" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:191 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:183 msgid "failed to create output/cache/gzip file directory" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:187 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:179 msgid "failed to download" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:186 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:178 msgid "failed to download Config Update file" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:177 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:169 msgid "failed to format data file" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:182 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:174 msgid "failed to move '%s' to '%s'" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:178 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:170 msgid "failed to move temporary data file to '%s'" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:175 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:167 msgid "failed to optimize data file" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:189 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:181 msgid "failed to parse" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:188 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:180 msgid "failed to parse Config Update file" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:176 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:168 msgid "failed to process allow-list" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:185 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:177 msgid "failed to reload/restart DNS resolver" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:180 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:172 msgid "failed to remove temporary files" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:172 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:164 msgid "failed to restart/reload DNS resolver" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:174 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:166 msgid "failed to sort data file" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:184 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:176 msgid "failed to stop %s" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:181 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:173 msgid "failed to unpack compressed cache" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:190 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/simple-adblock/status.js:182 msgid "no HTTPS/SSL support on device" msgstr "" -#: applications/luci-app-simple-adblock/luasrc/model/cbi/simple-adblock.lua:290 +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:59 msgid "none" msgstr "" + +#: applications/luci-app-simple-adblock/htdocs/luci-static/resources/view/simple-adblock/overview.js:99 +msgid "unbound adblock list" +msgstr "" diff --git a/applications/luci-app-simple-adblock/root/etc/uci-defaults/40_luci-simple-adblock b/applications/luci-app-simple-adblock/root/etc/uci-defaults/40_luci-simple-adblock index b42fa5859f..080086891a 100644 --- a/applications/luci-app-simple-adblock/root/etc/uci-defaults/40_luci-simple-adblock +++ b/applications/luci-app-simple-adblock/root/etc/uci-defaults/40_luci-simple-adblock @@ -1,4 +1,4 @@ #!/bin/sh rm -rf /var/luci-modulecache/; rm -f /var/luci-indexcache; -[ -x /etc/init.d/rpcd ] && /etc/init.d/rpcd reload +[ -x /etc/init.d/rpcd ] && /etc/init.d/rpcd reload; exit 0 diff --git a/applications/luci-app-simple-adblock/root/usr/libexec/rpcd/luci.simple-adblock b/applications/luci-app-simple-adblock/root/usr/libexec/rpcd/luci.simple-adblock new file mode 100755 index 0000000000..80938a3b0b --- /dev/null +++ b/applications/luci-app-simple-adblock/root/usr/libexec/rpcd/luci.simple-adblock @@ -0,0 +1,312 @@ +#!/bin/sh +# Copyright 2022 Stan Grishin (stangri@melmac.ca) +# shellcheck disable=SC1091,SC2018,SC2019,SC2039,SC3043,SC3057,SC3060 + +# TechRef: https://openwrt.org/docs/techref/rpcd +# TESTS +# ubus -v list luci.simple-adblock +# ubus -S call luci.simple-adblock getInitList '{"name": "simple-adblock" }' +# ubus -S call luci.simple-adblock getInitStatus '{"name": "simple-adblock" }' +# ubus -S call luci.simple-adblock getPlatformSupport '{"name": "simple-adblock" }' + +. /lib/functions.sh +. /lib/functions/network.sh +. /usr/share/libubox/jshn.sh + +readonly packageName="simple-adblock" +readonly dnsmasqAddnhostsFile="/var/run/${packageName}/dnsmasq.addnhosts" +readonly dnsmasqAddnhostsCache="/var/run/${packageName}/dnsmasq.addnhosts.cache" +readonly dnsmasqAddnhostsGzip="/etc/${packageName}.dnsmasq.addnhosts.gz" +readonly dnsmasqConfFile="/tmp/dnsmasq.d/${packageName}" +readonly dnsmasqConfCache="/var/run/${packageName}/dnsmasq.conf.cache" +readonly dnsmasqConfGzip="/etc/${packageName}.dnsmasq.conf.gz" +readonly dnsmasqIpsetFile="/tmp/dnsmasq.d/${packageName}.ipset" +readonly dnsmasqIpsetCache="/var/run/${packageName}/dnsmasq.ipset.cache" +readonly dnsmasqIpsetGzip="/etc/${packageName}.dnsmasq.ipset.gz" +readonly dnsmasqNftsetFile="/tmp/dnsmasq.d/${packageName}.nftset" +readonly dnsmasqNftsetCache="/var/run/${packageName}/dnsmasq.nftset.cache" +readonly dnsmasqNftsetGzip="/etc/${packageName}.dnsmasq.nftset.gz" +readonly dnsmasqServersFile="/var/run/${packageName}/dnsmasq.servers" +readonly dnsmasqServersCache="/var/run/${packageName}/dnsmasq.servers.cache" +readonly dnsmasqServersGzip="/etc/${packageName}.dnsmasq.servers.gz" +readonly unboundFile="/var/lib/unbound/adb_list.${packageName}" +readonly unboundCache="/var/run/${packageName}/unbound.cache" +readonly unboundGzip="/etc/${packageName}.unbound.gz" +readonly jsonFile="/var/run/${packageName}/${packageName}.json" + +str_contains() { [ -n "$1" ] &&[ -n "$2" ] && [ "${1//$2}" != "$1" ]; } +str_contains_word() { echo "$1" | grep -q -w "$2"; } +str_to_lower() { echo "$1" | tr 'A-Z' 'a-z'; } +str_to_upper() { echo "$1" | tr 'a-z' 'A-Z'; } +is_enabled() { uci -q get "${1}.config.enabled"; } +get_version() { grep -m1 -A2 -w "^Package: $1$" /usr/lib/opkg/status | sed -n 's/Version: //p'; } +print_json_bool() { json_init; json_add_boolean "$1" "$2"; json_dump; json_cleanup; } +print_json_string() { json_init; json_add_string "$1" "$2"; json_dump; json_cleanup; } +logger() { /usr/bin/logger -t "$packageName" "$@"; } +ubus_get_status() { ubus call service list "{ 'name': '$packageName' }" | jsonfilter -e "@['${packageName}'].instances.main.data.${1}"; } +ubus_get_ports() { ubus call service list "{ 'name': '$packageName' }" | jsonfilter -e "@['${packageName}'].instances.main.data.firewall.*.dest_port"; } +json() { +# shellcheck disable=SC2034 + local action="$1" param="$2" value="$3" i + if [ -s "$jsonFile" ]; then + json_load_file "$jsonFile" 2>/dev/null + json_select 'data' 2>/dev/null + for i in status message error stats reload restart; do + json_get_var $i "$i" 2>/dev/null + done + fi + case "$action" in + get) + case "$param" in + *) + printf "%b" "$(eval echo "\$$param")"; return;; + esac + ;; + esac +} + +get_init_list() { + local name + name="$(basename "$1")" + name="${name:-$packageName}" + json_init + json_add_object "$name" + json_add_boolean 'enabled' "$(is_enabled "$name")" + if is_running "$name"; then + json_add_boolean 'running' '1' + else + json_add_boolean 'running' '0' + fi + json_close_object + json_dump + json_cleanup +} + +set_init_action() { + local name action="$2" cmd + name="$(basename "$1")" + name="${name:-$packageName}" + if [ ! -f "/etc/init.d/$name" ]; then + print_json_string 'error' 'Init script not found!' + return + fi + case $action in + enable) + cmd="uci -q set ${name}.config.enabled=1 && uci commit $name";; + disable) + cmd="uci -q set ${name}.config.enabled=0 && uci commit $name";; + start|stop|reload|restart) + cmd="/etc/init.d/${name} ${action}";; + esac + if [ -n "$cmd" ] && eval "${cmd}" 1>/dev/null 2>&1; then + print_json_bool "result" '1' + else + print_json_bool "result" '0' + fi +} + +get_init_status() { + local name + name="$(basename "$1")" + name="${name:-$packageName}" + local errors ports dns outputFile outputCache outputGzip + local i + errors="$(ubus_get_status errors)" + ports="$(ubus_get_ports)" + dns="$(uci -q get $packageName.config.dns)" + case "$dns" in + dnsmasq.addnhosts) + outputFile="$dnsmasqAddnhostsFile" + outputCache="$dnsmasqAddnhostsCache" + outputGzip="$dnsmasqAddnhostsGzip" + ;; + dnsmasq.conf) + outputFile="$dnsmasqConfFile" + outputCache="$dnsmasqConfCache" + outputGzip="$dnsmasqConfGzip" + ;; + dnsmasq.ipset) + outputFile="$dnsmasqIpsetFile" + outputCache="$dnsmasqIpsetCache" + outputGzip="$dnsmasqIpsetGzip" + ;; + dnsmasq.nftset) + outputFile="$dnsmasqNftsetFile" + outputCache="$dnsmasqNftsetCache" + outputGzip="$dnsmasqNftsetGzip" + ;; + dnsmasq.servers) + outputFile="$dnsmasqServersFile" + outputCache="$dnsmasqServersCache" + outputGzip="$dnsmasqServersGzip" + ;; + unbound.adb_list) + outputFile="$unboundFile" + outputCache="$unboundCache" + outputGzip="$unboundGzip" + ;; + esac + json_init + json_add_object "$name" + json_add_boolean 'enabled' "$(is_enabled "$name")" + i="$(json 'get' 'status')" + json_add_string 'status' "$i" + if [ "$i" = 'statusSuccess' ]; then + json_add_boolean 'running' '1' + else + json_add_boolean 'running' '0' + fi + json_add_string 'version' "$(get_version "$name")" + json_add_array 'errors' + for i in $errors; do json_add_string '' "$i"; done + json_close_array + if [ -n "$ports" ]; then + json_add_boolean 'force_dns_active' '1' + json_add_array 'force_dns_ports' + for i in $ports; do json_add_int '' "$i"; done + json_close_array + else + json_add_boolean 'force_dns_active' '0' + fi + json_add_int 'entries' "$(ubus_get_status entries)" + json_add_string 'dns' "$dns" + json_add_string 'outputFile' "$outputFile" + json_add_string 'outputCache' "$outputCache" + json_add_string 'outputGzip' "$outputGzip" + if [ -s "$outputFile" ]; then + json_add_boolean 'outputFileExists' '1' + else + json_add_boolean 'outputFileExists' '0' + fi + if [ -s "$outputCache" ]; then + json_add_boolean 'outputCacheExists' '1' + else + json_add_boolean 'outputCacheExists' '0' + fi + if [ -s "$outputGzip" ]; then + json_add_boolean 'outputGzipExists' '1' + else + json_add_boolean 'outputGzipExists' '0' + fi + json_add_array 'leds' + for i in /sys/class/leds/*; do json_add_string '' "$(basename "$i")"; done + json_close_array + json_close_object + json_dump + json_cleanup +} + +check_ipset() { { command -v ipset && /usr/sbin/ipset help hash:net; } >/dev/null 2>&1; } +check_nft() { command -v nft >/dev/null 2>&1; } +check_dnsmasq() { command -v dnsmasq >/dev/null 2>&1; } +check_unbound() { command -v unbound >/dev/null 2>&1; } +check_dnsmasq_ipset() { + local o; + check_dnsmasq || return 1 + o="$(dnsmasq -v 2>/dev/null)" + check_ipset && ! echo "$o" | grep -q 'no-ipset' && echo "$o" | grep -q 'ipset' +} +check_dnsmasq_nftset() { + local o; + check_dnsmasq || return 1 + o="$(dnsmasq -v 2>/dev/null)" + check_nft && ! echo "$o" | grep -q 'no-nftset' && echo "$o" | grep -q 'nftset' +} + +get_platform_support() { + local name + name="$(basename "$1")" + name="${name:-$packageName}" + json_init + json_add_object "$name" + if check_ipset; then + json_add_boolean 'ipset_installed' '1' + else + json_add_boolean 'ipset_installed' '0' + fi + if check_nft; then + json_add_boolean 'nft_installed' '1' + else + json_add_boolean 'nft_installed' '0' + fi + if check_dnsmasq; then + json_add_boolean 'dnsmasq_installed' '1' + else + json_add_boolean 'dnsmasq_installed' '0' + fi + if check_unbound; then + json_add_boolean 'unbound_installed' '1' + else + json_add_boolean 'unbound_installed' '0' + fi + if check_dnsmasq_ipset; then + json_add_boolean 'dnsmasq_ipset_support' '1' + else + json_add_boolean 'dnsmasq_ipset_support' '0' + fi + if check_dnsmasq_nftset; then + json_add_boolean 'dnsmasq_nftset_support' '1' + else + json_add_boolean 'dnsmasq_nftset_support' '0' + fi + json_add_array 'leds' + for i in /sys/class/leds/*; do json_add_string '' "$(basename "$i")"; done + json_close_array + json_close_object + json_dump + json_cleanup +} + +case "$1" in + list) + json_init + json_add_object "getInitList" + json_add_string 'name' 'name' + json_close_object + json_add_object "getInitStatus" + json_add_string 'name' 'name' + json_close_object + json_add_object "getPlatformSupport" + json_add_string 'name' 'name' + json_close_object + json_add_object "setInitAction" + json_add_string 'name' 'name' + json_add_string 'action' 'action' + json_close_object + json_dump + json_cleanup + ;; + call) + case "$2" in + getInitList) + read -r input + json_load "$input" + json_get_var name 'name' + json_cleanup + get_init_list "$name" + ;; + getInitStatus) + read -r input + json_load "$input" + json_get_var name 'name' + json_cleanup + get_init_status "$name" + ;; + getPlatformSupport) + read -r input + json_load "$input" + json_get_var name 'name' + json_cleanup + get_platform_support "$name" + ;; + setInitAction) + read -r input + json_load "$input" + json_get_var name 'name' + json_get_var action 'action' + json_cleanup + set_init_action "$name" "$action" + ;; + esac + ;; +esac diff --git a/applications/luci-app-simple-adblock/root/usr/share/luci/menu.d/luci-app-simple-adblock.json b/applications/luci-app-simple-adblock/root/usr/share/luci/menu.d/luci-app-simple-adblock.json index e640dbb871..b2cdca18eb 100644 --- a/applications/luci-app-simple-adblock/root/usr/share/luci/menu.d/luci-app-simple-adblock.json +++ b/applications/luci-app-simple-adblock/root/usr/share/luci/menu.d/luci-app-simple-adblock.json @@ -2,13 +2,16 @@ "admin/services/simple-adblock": { "title": "Simple AdBlock", "action": { - "type": "cbi", - "path": "simple-adblock", - "post": { "cbi.submit": true } + "type": "view", + "path": "simple-adblock/overview" }, "depends": { - "acl": [ "luci-app-simple-adblock" ], - "uci": { "simple-adblock": true } + "acl": [ + "luci-app-simple-adblock" + ], + "uci": { + "simple-adblock": true + } } } } diff --git a/applications/luci-app-simple-adblock/root/usr/share/rpcd/acl.d/luci-app-simple-adblock.json b/applications/luci-app-simple-adblock/root/usr/share/rpcd/acl.d/luci-app-simple-adblock.json index 4635626615..6aeadc9c63 100644 --- a/applications/luci-app-simple-adblock/root/usr/share/rpcd/acl.d/luci-app-simple-adblock.json +++ b/applications/luci-app-simple-adblock/root/usr/share/rpcd/acl.d/luci-app-simple-adblock.json @@ -2,40 +2,26 @@ "luci-app-simple-adblock": { "description": "Grant UCI and file access for luci-app-simple-adblock", "read": { - "cgi-io": [ - "exec" - ], - "file": { - "/usr/lib/opkg/status": [ - "read" - ], - "/sys/class/leds/*": [ - "read" - ], - "/var/run/simple-adblock.*": [ - "read" - ], - "/etc/init.d/simple-adblock *": [ - "exec" - ], - "/usr/sbin/dnsmasq *": [ - "exec" - ], - "/usr/sbin/unbound *": [ - "exec" - ], - "/usr/sbin/ipset *": [ - "exec" + "ubus": { + "luci.simple-adblock": [ + "getInitList", + "getInitStatus", + "getPlatformSupport" ] }, - "uci": [ + "uci": [ "simple-adblock" ] }, "write": { "uci": [ "simple-adblock" - ] + ], + "ubus": { + "luci.simple-adblock": [ + "setInitAction" + ] + } } } -} \ No newline at end of file +} -- 2.30.2