adblock: update to 4.1.2 15547/head
authorDirk Brenken <dev@brenken.org>
Fri, 30 Apr 2021 10:02:21 +0000 (12:02 +0200)
committerDirk Brenken <dev@brenken.org>
Fri, 30 Apr 2021 14:40:08 +0000 (16:40 +0200)
* preserve DNS cache after adblock processing (unbound & bind)
* fix redirect issue with oisd basic url
* cosmetics

Signed-off-by: Dirk Brenken <dev@brenken.org>
net/adblock/Makefile
net/adblock/files/README.md
net/adblock/files/adblock.sh
net/adblock/files/adblock.sources

index 7e5bd50adb3f3d9434958a0b108cb4d8058c8192..ad77e3d63a611e1eee601f206d48c7e0f5f78b63 100644 (file)
@@ -6,7 +6,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=adblock
-PKG_VERSION:=4.1.1
+PKG_VERSION:=4.1.2
 PKG_RELEASE:=1
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
index 183b3ecfac816b3fc67de35ef0bb1643c04a2e05..76b92dc81ea8a41ab179a497a9bcdeaa786ae7b4 100644 (file)
@@ -186,10 +186,12 @@ Available commands:
 
 ## Examples
 **Change the DNS backend to 'unbound':**  
-No further configuration is needed, adblock deposits the final blocklist 'adb_list.overall' in '/var/lib/unbound' by default.
+No further configuration is needed, adblock deposits the final blocklist 'adb_list.overall' in '/var/lib/unbound' by default.  
+To preserve the DNS cache after adblock processing please install the additional package 'unbound-control'.
 
-**Change the DNS backend to 'named' (bind):**  
-Adblock deposits the final blocklist 'adb_list.overall' in '/var/lib/bind'.  
+**Change the DNS backend to 'bind':**  
+Adblock deposits the final blocklist 'adb_list.overall' in '/var/lib/bind' by default.  
+To preserve the DNS cache after adblock processing please install the additional package 'bind-rdnc'.
 To use the blocklist please modify '/etc/bind/named.conf':
 <pre><code>
 in the 'options' namespace add:
index d87cf70a39bb21ca014aa65f230197623e5ec935..051aace3e37debd12abce47d06ad0361bc37d34d 100755 (executable)
@@ -11,7 +11,7 @@
 export LC_ALL=C
 export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
 set -o pipefail
-adb_ver="4.1.1"
+adb_ver="4.1.2"
 adb_enabled=0
 adb_debug=0
 adb_forcedns=0
@@ -260,6 +260,21 @@ f_conf()
        fi
 }
 
+# status helper function
+#
+f_char()
+{
+       local result input="${1}"
+
+       if [ "${input}" = "1" ]
+       then
+               result="✔"
+       else
+               result="✘"
+       fi
+       printf "%s" "${result}"
+}
+
 # load dns backend config
 #
 f_dns()
@@ -298,6 +313,7 @@ f_dns()
        then
                case "${adb_dns}" in
                        "dnsmasq")
+                               adb_dnscachecmd="-"
                                adb_dnsinotify="${adb_dnsinotify:-"0"}"
                                adb_dnsinstance="${adb_dnsinstance:-"0"}"
                                adb_dnsuser="${adb_dnsuser:-"dnsmasq"}"
@@ -309,6 +325,7 @@ f_dns()
                                adb_dnsstop="${adb_dnsstop:-"address=/#/"}"
                        ;;
                        "unbound")
+                               adb_dnscachecmd="$(command -v unbound-control || printf "%s" "-")"
                                adb_dnsinotify="${adb_dnsinotify:-"0"}"
                                adb_dnsinstance="${adb_dnsinstance:-"0"}"
                                adb_dnsuser="${adb_dnsuser:-"unbound"}"
@@ -320,6 +337,7 @@ f_dns()
                                adb_dnsstop="${adb_dnsstop:-"local-zone: \".\" static"}"
                        ;;
                        "named")
+                               adb_dnscachecmd="$(command -v rndc || printf "%s" "-")"
                                adb_dnsinotify="${adb_dnsinotify:-"0"}"
                                adb_dnsinstance="${adb_dnsinstance:-"0"}"
                                adb_dnsuser="${adb_dnsuser:-"bind"}"
@@ -333,6 +351,7 @@ f_dns()
                                adb_dnsstop="${adb_dnsstop:-"* CNAME ."}"
                        ;;
                        "kresd")
+                               adb_dnscachecmd="-"
                                adb_dnsinotify="${adb_dnsinotify:-"0"}"
                                adb_dnsinstance="${adb_dnsinstance:-"0"}"
                                adb_dnsuser="${adb_dnsuser:-"root"}"
@@ -344,6 +363,7 @@ f_dns()
                                adb_dnsstop="${adb_dnsstop:-"* CNAME ."}"
                        ;;
                        "raw")
+                               adb_dnscachecmd="-"
                                adb_dnsinotify="${adb_dnsinotify:-"0"}"
                                adb_dnsinstance="${adb_dnsinstance:-"0"}"
                                adb_dnsuser="${adb_dnsuser:-"root"}"
@@ -727,8 +747,40 @@ f_dnsup()
        then
                out_rc=0
        else
-               "/etc/init.d/${adb_dns}" restart >/dev/null 2>&1
-               restart_rc="${?}"
+               if [ "${in_rc}" = "0" ] && [ "${adb_dnsflush}" = "0" ]
+               then
+                       case "${adb_dns}" in
+                               "unbound")
+                                       if [ -x "${adb_dnscachecmd}" ] && [ -d "${adb_tmpdir}" ] && [ -f "${adb_dnsdir}/unbound.conf" ]
+                                       then
+                                               "${adb_dnscachecmd}" -c "${adb_dnsdir}/unbound.conf" dump_cache > "${adb_tmpdir}/adb_cache.dump" 2>/dev/null
+                                       fi
+                                       "/etc/init.d/${adb_dns}" restart >/dev/null 2>&1
+                                       restart_rc="${?}"
+                               ;;
+                               "named")
+                                       if [ -x "${adb_dnscachecmd}" ] && [ -f "/etc/bind/rndc.conf" ]
+                                       then
+                                               "${adb_dnscachecmd}" -c "/etc/bind/rndc.conf" reload >/dev/null 2>&1
+                                               restart_rc="${?}"
+                                       fi
+                                       if [ -z "${restart_rc}" ] || { [ -n "${restart_rc}" ] && [ "${restart_rc}" != "0" ]; }
+                                       then
+                                               "/etc/init.d/${adb_dns}" restart >/dev/null 2>&1
+                                               restart_rc="${?}"
+                                       fi
+                               ;;
+                               *)
+                                       "/etc/init.d/${adb_dns}" restart >/dev/null 2>&1
+                                       restart_rc="${?}"
+                               ;;
+                       esac
+               fi
+               if [ -z "${restart_rc}" ]
+               then
+                       "/etc/init.d/${adb_dns}" restart >/dev/null 2>&1
+                       restart_rc="${?}"
+               fi
        fi
        if [ "${restart_rc}" = "0" ]
        then
@@ -758,8 +810,16 @@ f_dnsup()
                        cnt=$((cnt+1))
                        sleep 1
                done
+               if [ "${out_rc}" = "0" ] && [ "${adb_dns}" = "unbound" ]
+               then
+                       if [ -x "${adb_dnscachecmd}" ] && [ -d "${adb_tmpdir}" ] && [ -s "${adb_tmpdir}/adb_cache.dump" ]
+                       then
+                               "${adb_dnscachecmd}" -c "${adb_dnsdir}/unbound.conf" load_cache < "${adb_tmpdir}/adb_cache.dump" >/dev/null 2>&1
+                               restart_rc="${?}"
+                       fi
+               fi
        fi
-       f_log "debug" "f_dnsup  ::: lookup_util: ${adb_lookupcmd:-"-"}, lookup_domain: ${adb_lookupdomain:-"-"}, restart_rc: ${restart_rc:-"-"}, dns_timeout: ${adb_dnstimeout}, dns_cnt: ${cnt}, in_rc: ${in_rc}, out_rc: ${out_rc}"
+       f_log "debug" "f_dnsup  ::: dns: ${adb_dns}, cache_cmd: ${adb_dnscachecmd:-"-"}, lookup_cmd: ${adb_lookupcmd:-"-"}, lookup_domain: ${adb_lookupdomain:-"-"}, restart_rc: ${restart_rc:-"-"}, dns_flush: ${adb_dnsflush}, dns_inotify: ${adb_dnsinotify}, dns_timeout: ${adb_dnstimeout}, dns_cnt: ${cnt}, in_rc: ${in_rc}, out_rc: ${out_rc}"
        return "${out_rc}"
 }
 
@@ -1236,12 +1296,7 @@ f_jsnup()
        json_load_file "${adb_rtfile}" >/dev/null 2>&1
        if [ "${?}" = "0" ]
        then
-               if [ -z "${adb_fetchutil}" ] || [ -z "${adb_awk}" ]
-               then
-                       json_get_var utils "utilities"
-               else
-                       utils="${adb_fetchutil}, ${adb_awk}"
-               fi
+               utils="download: $(readlink -fn "${adb_fetchutil}"), sort: $(readlink -fn "${adb_sort}"), awk: $(readlink -fn "${adb_awk}")"
                if [ -z "${adb_cnt}" ]
                then
                        json_get_var adb_cnt "blocked_domains"
@@ -1275,11 +1330,11 @@ f_jsnup()
                json_close_object
        done
        json_close_array
-       json_add_string "dns_backend" "${adb_dns:-"-"}, ${adb_dnsdir:-"-"}"
+       json_add_string "dns_backend" "${adb_dns:-"-"} (${adb_dnscachecmd##*/}), ${adb_dnsdir:-"-"}"
        json_add_string "run_utils" "${utils:-"-"}"
        json_add_string "run_ifaces" "trigger: ${adb_trigger:-"-"}, report: ${adb_repiface:-"-"}"       
        json_add_string "run_directories" "base: ${adb_tmpbase}, backup: ${adb_backupdir}, report: ${adb_reportdir}, jail: ${adb_jaildir}"
-       json_add_string "run_flags" "backup: ${adb_backup}, flush: ${adb_dnsflush}, force: ${adb_forcedns}, search: ${adb_safesearch}, report: ${adb_report}, mail: ${adb_mail}, jail: ${adb_jail}"
+       json_add_string "run_flags" "backup: $(f_char ${adb_backup}), flush: $(f_char ${adb_dnsflush}), force: $(f_char ${adb_forcedns}), search: $(f_char ${adb_safesearch}), report: $(f_char ${adb_report}), mail: $(f_char ${adb_mail}), jail: $(f_char ${adb_jail})"
        json_add_string "last_run" "${runtime:-"-"}"
        json_add_string "system" "${adb_sysver}"
        json_dump > "${adb_rtfile}"
@@ -1753,36 +1808,32 @@ else
        f_log "err" "system libraries not found"
 fi
 
-# awk selection
+# version information
 #
-adb_awk="$(command -v gawk)"
-if [ -z "${adb_awk}" ]
+if [ "${adb_action}" = "version" ]
 then
-       adb_awk="$(command -v awk)"
-       if [ -z "${adb_awk}" ]
-       then
-               f_log "err" "awk not found"
-       fi
+       printf "%s\n" "${adb_ver}"
+       exit 0
 fi
 
-# sort selection
+# awk check
 #
-adb_sort="$(command -v /usr/libexec/sort-coreutils)"
-if [ -z "${adb_sort}" ]
+adb_awk="$(command -v gawk)"
+if [ ! -x "${adb_awk}" ]
 then
-       adb_sort="$(command -v sort)"
-       if [ -z "$("${adb_sort}" --help 2>/dev/null | grep -Fo -m1 "coreutils")" ]
+       adb_awk="$(command -v awk)"
+       if [ ! -x "${adb_awk}" ]
        then
-               f_log "err" "coreutils sort not found"
+               f_log "err" "awk not found or not executable"
        fi
 fi
 
-# version information
+# sort check
 #
-if [ "${adb_action}" = "version" ]
+adb_sort="$(command -v sort)"
+if [ ! -x "${adb_sort}" ] || [ "$("${adb_sort}" --version 2>/dev/null | grep -c "coreutils")" = "0" ]
 then
-       printf "%s\n" "${adb_ver}"
-       exit 0
+       f_log "err" "coreutils sort not found or not executable"
 fi
 
 # handle different adblock actions
index 259753bbf1b34f3ed8c812f807f49994cd2f004e..6f8463b4325022c9348b1eb0f68723d60672a835 100644 (file)
@@ -98,7 +98,7 @@
                "descurl": "https://github.com/notracking/hosts-blocklists"
        },
        "oisd_basic": {
-               "url": "https://dbl.oisd.nl/basic",
+               "url": "https://dbl.oisd.nl/basic/",
                "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
                "size": "L",
                "focus": "general",
                "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
                "size": "S",
                "focus": "general",
-               "descurl": "https://pgl.yoyo.org"
+               "descurl": "https://pgl.yoyo.org/as"
        }
 }