From d36fd5766226698957e09936f366da1f7be89096 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Sun, 18 Oct 2020 11:05:22 +0200 Subject: [PATCH] adblock: update 4.0.7 * fix aria2c download options * fix report engine with empty domains * fix safesearch ips of safe.duckduckgo.com (get ips dynamically) * fix safesearch ips of safesearch.pixabay.com (get ips dynamically) * add regional blocklist for italy * shellcheck adjustments * add test.sh for CI testing Signed-off-by: Dirk Brenken --- net/adblock/Makefile | 4 ++-- net/adblock/files/README.md | 3 +++ net/adblock/files/adblock.init | 13 +++++++++-- net/adblock/files/adblock.mail | 3 +++ net/adblock/files/adblock.monitor | 3 +++ net/adblock/files/adblock.sh | 37 ++++++++++++++++++++++++------- net/adblock/files/adblock.sources | 7 ++++++ net/adblock/test.sh | 3 +++ 8 files changed, 61 insertions(+), 12 deletions(-) create mode 100755 net/adblock/test.sh diff --git a/net/adblock/Makefile b/net/adblock/Makefile index 8d2ab9a75..da1d30cfe 100644 --- a/net/adblock/Makefile +++ b/net/adblock/Makefile @@ -6,8 +6,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=adblock -PKG_VERSION:=4.0.6 -PKG_RELEASE:=3 +PKG_VERSION:=4.0.7 +PKG_RELEASE:=1 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/adblock/files/README.md b/net/adblock/files/README.md index 29a1ff8e7..6b9f29274 100644 --- a/net/adblock/files/README.md +++ b/net/adblock/files/README.md @@ -1,3 +1,5 @@ + + # DNS based ad/abuse domain blocking ## Description @@ -36,6 +38,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but | reg_fi | | S | reg_finland | [Link](https://github.com/finnish-easylist-addition) | | reg_fr | | S | reg_france | [Link](https://forums.lanik.us/viewforum.php?f=91) | | reg_id | | M | reg_indonesia | [Link](https://easylist.to) | +| reg_it | | M | reg_italy | [Link](https://easylist.to) | | reg_kr | | S | reg_korea | [Link](https://list-kr.github.io) | | reg_nl | | M | reg_netherlands | [Link](https://easylist.to) | | reg_pl1 | | S | reg_poland | [Link](https://kadantiscam.netlify.com) | diff --git a/net/adblock/files/adblock.init b/net/adblock/files/adblock.init index 780e3b6bd..64dbd7684 100755 --- a/net/adblock/files/adblock.init +++ b/net/adblock/files/adblock.init @@ -2,16 +2,20 @@ # Copyright (c) 2015-2020 Dirk Brenken (dev@brenken.org) # This is free software, licensed under the GNU General Public License v3. +# set (s)hellcheck exceptions +# shellcheck disable=1091,2010,2016,2034,2039,2059,2086,2091,2129,2143,2154,2181,2183,2188 + START=30 USE_PROCD=1 -EXTRA_COMMANDS="suspend resume query report list timer status_service" +EXTRA_COMMANDS="suspend resume query report list timer status_service version" EXTRA_HELP=" suspend Suspend adblock processing resume Resume adblock processing query Query active blocklists and backups for a specific domain report [] Print DNS statistics with an optional search parameter list [[|] [source(s)]] List available adblock sources or add/remove them from config - timer [] [] Set a cron based update interval" + timer [] [] Set a cron based update interval + version print version information" adb_init="/etc/init.d/adblock" adb_script="/usr/bin/adblock.sh" @@ -25,6 +29,11 @@ then exit 0 fi +version() +{ + rc_procd "${adb_script}" version +} + boot() { [ -s "${adb_pidfile}" ] && > "${adb_pidfile}" diff --git a/net/adblock/files/adblock.mail b/net/adblock/files/adblock.mail index ca9d206d1..0683ede31 100755 --- a/net/adblock/files/adblock.mail +++ b/net/adblock/files/adblock.mail @@ -5,6 +5,9 @@ # Please note: you have to manually install and configure the package 'msmtp' before using this script +# set (s)hellcheck exceptions +# shellcheck disable=1091,2010,2016,2034,2039,2059,2086,2091,2129,2143,2154,2181,2183,2188 + LC_ALL=C PATH="/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/net/adblock/files/adblock.monitor b/net/adblock/files/adblock.monitor index 7fe90c8c9..b5b73673d 100755 --- a/net/adblock/files/adblock.monitor +++ b/net/adblock/files/adblock.monitor @@ -3,6 +3,9 @@ # Copyright (c) 2015-2020 Dirk Brenken (dev@brenken.org) # This is free software, licensed under the GNU General Public License v3. +# set (s)hellcheck exceptions +# shellcheck disable=1091,2010,2016,2034,2039,2059,2086,2091,2129,2143,2154,2181,2183,2188 + LC_ALL=C PATH="/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/net/adblock/files/adblock.sh b/net/adblock/files/adblock.sh index d545a6706..fcbb64f93 100755 --- a/net/adblock/files/adblock.sh +++ b/net/adblock/files/adblock.sh @@ -4,14 +4,14 @@ # This is free software, licensed under the GNU General Public License v3. # set (s)hellcheck exceptions -# shellcheck disable=1091,2016,2039,2059,2086,2143,2181,2188 +# shellcheck disable=1091,2010,2016,2034,2039,2059,2086,2091,2129,2143,2154,2181,2183,2188 # set initial defaults # export LC_ALL=C export PATH="/usr/sbin:/usr/bin:/sbin:/bin" set -o pipefail -adb_ver="4.0.6" +adb_ver="4.0.7" adb_enabled=0 adb_debug=0 adb_forcedns=0 @@ -386,7 +386,7 @@ f_fetch() fi case "${adb_fetchutil}" in "aria2c") - adb_fetchparm="${adb_fetchparm:-"--timeout=20 --allow-overwrite=true --auto-file-renaming=false --check-certificate=true --dir= -o"}" + adb_fetchparm="${adb_fetchparm:-"--timeout=20 --allow-overwrite=true --auto-file-renaming=false --check-certificate=true --log-level=warn --dir=/ -o"}" ;; "curl") adb_fetchparm="${adb_fetchparm:-"--connect-timeout 20 --silent --show-error --location -o"}" @@ -753,17 +753,30 @@ f_list() out_rc="${?}" ;; "duckduckgo") - safe_ips="50.16.250.179 54.208.102.2 52.204.96.252" safe_cname="safe.duckduckgo.com" safe_domains="duckduckgo.com" - printf "%s\n" ${safe_domains} > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" + if [ -x "${adb_lookupcmd}" ] + then + safe_ips="$("${adb_lookupcmd}" "${safe_cname}" 2>/dev/null | "${adb_awk}" '/Address [0-9]+:/{ORS=" ";print $3}')" + if [ -n "${safe_ips}" ] + then + printf "%s\n" ${safe_domains} > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" + fi + fi out_rc="${?}" ;; "pixabay") - safe_ips="104.18.82.97 2606:4700::6812:8d57 2606:4700::6812:5261" safe_cname="safesearch.pixabay.com" safe_domains="pixabay.com" printf "%s\n" ${safe_domains} > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" + if [ -x "${adb_lookupcmd}" ] + then + safe_ips="$("${adb_lookupcmd}" "${safe_cname}" 2>/dev/null | "${adb_awk}" '/Address [0-9]+:/{ORS=" ";print $3}')" + if [ -n "${safe_ips}" ] + then + printf "%s\n" ${safe_domains} > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" + fi + fi out_rc="${?}" ;; "yandex") @@ -787,7 +800,7 @@ f_list() out_rc="${?}" ;; esac - if [ "${out_rc}" -eq 0 ] + if [ "${out_rc}" -eq 0 ] && [ -f "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" ] then > "${adb_tmpdir}/tmp.safesearch.${src_name}" if [ "${adb_dns}" = "named" ] @@ -1469,7 +1482,7 @@ f_report() ( "${adb_dumpcmd}" -tttt -r "${file}" 2>/dev/null | \ "${adb_awk}" -v cnt="${cnt}" '!/\.lan\. |PTR\? | SOA\? /&&/ A[\? ]+|NXDomain|0\.0\.0\.0/{a=$1;b=substr($2,0,8);c=$4;sub(/\.[0-9]+$/,"",c);d=cnt $7;sub(/\*$/,"",d); - e=$(NF-1);sub(/[0-9]\/[0-9]\/[0-9]|0\.0\.0\.0/,"NX",e);sub(/\.$/,"",e);sub(/([0-9]{1,3}\.){3}[0-9]{1,3}/,"OK",e);printf "%s\t%s\t%s\t%s\t%s\n",d,e,a,b,c}' >> "${adb_reportdir}/adb_report.raw" + e=$(NF-1);sub(/[0-9]\/[0-9]\/[0-9]|0\.0\.0\.0/,"NX",e);sub(/\.$/,"",e);sub(/([0-9]{1,3}\.){3}[0-9]{1,3}/,"OK",e);if(e==""){e="err"};printf "%s\t%s\t%s\t%s\t%s\n",d,e,a,b,c}' >> "${adb_reportdir}/adb_report.raw" )& hold=$((cnt%adb_maxqueue)) if [ "${hold}" -eq 0 ] @@ -1615,6 +1628,14 @@ else f_log "err" "system libraries not found" fi +# version information +# +if [ "${adb_action}" = "version" ] +then + printf "%s\n" "${adb_ver}" + exit 0 +fi + # handle different adblock actions # f_load diff --git a/net/adblock/files/adblock.sources b/net/adblock/files/adblock.sources index e198092df..dfb9f1bae 100644 --- a/net/adblock/files/adblock.sources +++ b/net/adblock/files/adblock.sources @@ -195,6 +195,13 @@ "focus": "reg_indonesia", "descurl": "https://easylist.to" }, + "reg_it": { + "url": "https://easylist-downloads.adblockplus.org/easylistitaly+easylist.txt", + "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}", + "size": "M", + "focus": "reg_italy", + "descurl": "https://easylist.to" + }, "reg_kr": { "url": "https://raw.githubusercontent.com/List-KR/List-KR/master/filter.txt", "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}", diff --git a/net/adblock/test.sh b/net/adblock/test.sh new file mode 100755 index 000000000..607de9758 --- /dev/null +++ b/net/adblock/test.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +/etc/init.d/"${1}" version 2>/dev/null | grep "${2}"