adblock-fast: bugfix: allow command
authorStan Grishin <redacted>
Sat, 21 Oct 2023 02:26:02 +0000 (02:26 +0000)
committerStan Grishin <redacted>
Sat, 21 Oct 2023 02:27:54 +0000 (02:27 +0000)
* fix sed to properly purge allowed domains from block-lists
* ensure resolver is restarted on allow command
* reduce pause default/max in attempt to make it work with luci

Signed-off-by: Stan Grishin <redacted>
net/adblock-fast/Makefile
net/adblock-fast/files/etc/config/adblock-fast
net/adblock-fast/files/etc/init.d/adblock-fast

index f923a27b4717f706796422fc25ee7734f12ce541..5c7936891c9bb944351a2c42c18cf33c61157f60 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=adblock-fast
 PKG_VERSION:=1.0.0
-PKG_RELEASE:=6
+PKG_RELEASE:=7
 PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>
 PKG_LICENSE:=GPL-3.0-or-later
 
index f459411f03fd5a7bc2725aeaf6f7e39b088dbf0b..e55475dd1a1db55ec816cc8c6ae9c3d0fec268c2 100644 (file)
@@ -29,6 +29,7 @@ config adblock-fast 'config'
 #      list force_dns_port '8443'
        option led 'none'
        option parallel_downloads '1'
+       option pause_timeout '20'
        option procd_trigger_wan6 '0'
        option procd_boot_wan_timeout '60'
        option verbosity '2'
index 8229f0845d7ee53acc64ee4121f30393d399c5ae..57fe5b93283cf2297e7dd65a560504fd31cb2d05 100755 (executable)
@@ -1155,7 +1155,7 @@ adb_allow() {
                        for c in $string; do
                                output 2 "  $c "
                                hf="$(echo "$c" | sed 's/\./\\./g')"
-                               if sed -i "/\(^\|\.\)${hf}$/d;" "$outputFile" && \
+                               if sed -i "\:\(/\|\.\)${hf}/:d" "$outputFile" && \
                                        uci_add_list_if_new "${packageName}" 'config' 'allowed_domain' "$c"; then
                                                output_ok
                                else
@@ -1171,7 +1171,7 @@ adb_allow() {
                                fi
                        fi
                        output 2 "Committing changes to config "
-                       if [ -n "$(uci_changes "$packageName")" ] && uci_commit "$packageName"; then
+                       if uci_commit "$packageName"; then
                                allowed_domain="$(uci_get "$packageName" 'config' 'allowed_domain')"
                                json set triggers
                                json set stats "$serviceName is blocking $(wc -l < "$outputFile") domains (with ${dns})"
@@ -1196,7 +1196,8 @@ adb_allow() {
                        output 2 "Allowing domain(s) \\n"
                        for c in $string; do 
                                output 2 "  $c "
-                               if sed -i "/${string}/d" "$outputFile" && \
+                               hf="$(echo "$c" | sed 's/\./\\./g')"
+                               if sed -i "\:\(\"\|\.\)${hf}\":d" "$outputFile" && \
                                        uci_add_list_if_new "$packageName" 'config' 'allowed_domain' "$string"; then
                                                output_ok
                                else
@@ -1212,7 +1213,7 @@ adb_allow() {
                                fi
                        fi
                        output 2 "Committing changes to config "
-                       if [ -n "$(uci_changes "$packageName")" ] && uci_commit "$packageName"; then
+                       if uci_commit "$packageName"; then
                                allowed_domain="$(uci_get "$packageName" 'config' 'allowed_domain')"
                                json set triggers
                                json set stats "$serviceName is blocking $(wc -l < "$outputFile") domains (with ${dns})"
@@ -1725,7 +1726,7 @@ load_validate_config() {
                'config_update_enabled:bool:0' \
                'config_update_url:string:https://cdn.jsdelivr.net/gh/openwrt/packages/net/adblock-fast/files/adblock-fast.conf.update' \
                'download_timeout:range(1,60):20' \
-               'pause_timeout:range(10,120):60' \
+               'pause_timeout:range(1,60):20' \
                'curl_additional_param:or("", string)' \
                'curl_max_file_size:or("", uinteger)' \
                'curl_retry:range(0,30):3' \
git clone https://git.99rst.org/PROJECT