From 4b0d029bb535229c1d5f71a8d90b8f7994ca2ae0 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Mon, 19 Oct 2020 09:32:37 +0200 Subject: [PATCH] adblock: update 4.0.7-2 * switch all safesearch providers to dynamic ips (derived from cname) * made the new safesearch approach compatible with bind-nslookup * removed 3.x config compatibility code Signed-off-by: Dirk Brenken --- net/adblock/Makefile | 2 +- net/adblock/files/adblock.sh | 69 +++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/net/adblock/Makefile b/net/adblock/Makefile index da1d30cfe4..023fdc22fb 100644 --- a/net/adblock/Makefile +++ b/net/adblock/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=adblock PKG_VERSION:=4.0.7 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/adblock/files/adblock.sh b/net/adblock/files/adblock.sh index fcbb64f93b..d096cce242 100755 --- a/net/adblock/files/adblock.sh +++ b/net/adblock/files/adblock.sh @@ -125,26 +125,9 @@ f_conf() { local cnt=0 cnt_max=10 - if [ ! -r "/etc/config/adblock" ] || [ -n "$(uci -q show adblock.@source[0])" ] + if [ ! -r "/etc/config/adblock" ] || [ -z "$(uci -q show adblock.global.adb_safesearch)" ] then - if { [ -r "/etc/config/adblock-opkg" ] && [ -z "$(uci -q show adblock-opkg.@source[0])" ]; } || \ - { [ -r "/rom/etc/config/adblock" ] && [ -z "$(uci -q show /rom/etc/config/adblock.@source[0])" ]; } - then - if [ -r "/etc/config/adblock" ] - then - cp -pf "/etc/config/adblock" "/etc/config/adblock-backup" - fi - if [ -r "/etc/config/adblock-opkg" ] - then - cp -pf "/etc/config/adblock-opkg" "/etc/config/adblock" - elif [ -r "/rom/etc/config/adblock" ] - then - cp -pf "/rom/etc/config/adblock" "/etc/config/adblock" - fi - f_log "info" "missing or old adblock config replaced with new valid default config" - else - f_log "err" "unrecoverable adblock config error, please re-install the package via opkg with the '--force-reinstall --force-maintainer' options" - fi + f_log "err" "no valid adblock config found, please re-install the package via opkg with the '--force-reinstall --force-maintainer' options" fi config_cb() @@ -724,7 +707,6 @@ f_list() "google") rset="/^(\\.[[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{printf \"%s\n%s\n\",tolower(\"www\"\$1),tolower(substr(\$1,2,length(\$1)))}" safe_url="https://www.google.com/supported_domains" - safe_ips="216.239.38.120 2001:4860:4802:32::78" safe_cname="forcesafesearch.google.com" safe_domains="${adb_tmpdir}/tmp.load.safesearch.${src_name}" if [ "${adb_backup}" -eq 1 ] && [ -s "${adb_backupdir}/safesearch.${src_name}.gz" ] @@ -741,15 +723,28 @@ f_list() fi if [ "${out_rc}" -eq 0 ] then - "${adb_awk}" "${rset}" "${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 $NF}')" + if [ -n "${safe_ips}" ] + then + "${adb_awk}" "${rset}" "${safe_domains}" > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" + fi + fi out_rc="${?}" fi ;; "bing") - safe_ips="204.79.197.220 ::FFFF:CC4F:C5DC" safe_cname="strict.bing.com" safe_domains="www.bing.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 $NF}')" + if [ -n "${safe_ips}" ] + then + printf "%s\n" ${safe_domains} > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" + fi + fi out_rc="${?}" ;; "duckduckgo") @@ -757,7 +752,7 @@ f_list() safe_domains="duckduckgo.com" if [ -x "${adb_lookupcmd}" ] then - safe_ips="$("${adb_lookupcmd}" "${safe_cname}" 2>/dev/null | "${adb_awk}" '/Address [0-9]+:/{ORS=" ";print $3}')" + safe_ips="$("${adb_lookupcmd}" "${safe_cname}" 2>/dev/null | "${adb_awk}" '/^Address[ 0-9]*: /{ORS=" ";print $NF}')" if [ -n "${safe_ips}" ] then printf "%s\n" ${safe_domains} > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" @@ -768,10 +763,9 @@ f_list() "pixabay") 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}')" + safe_ips="$("${adb_lookupcmd}" "${safe_cname}" 2>/dev/null | "${adb_awk}" '/^Address[ 0-9]*: /{ORS=" ";print $NF}')" if [ -n "${safe_ips}" ] then printf "%s\n" ${safe_domains} > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" @@ -780,27 +774,38 @@ f_list() out_rc="${?}" ;; "yandex") - safe_ips="213.180.193.56" safe_cname="familysearch.yandex.ru" safe_domains="ya.ru yandex.ru yandex.com yandex.com.tr yandex.ua yandex.by yandex.ee yandex.lt yandex.lv yandex.md yandex.uz yandex.tm yandex.tj yandex.az" - 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 $NF}')" + if [ -n "${safe_ips}" ] + then + printf "%s\n" ${safe_domains} > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" + fi + fi out_rc="${?}" ;; "youtube") if [ "${adb_safesearchmod}" -eq 0 ] then - safe_ips="216.239.38.120 2001:4860:4802:32::78" safe_cname="restrict.youtube.com" else - safe_ips="216.239.38.119 2001:4860:4802:32::77" safe_cname="restrictmoderate.youtube.com" fi safe_domains="www.youtube.com m.youtube.com youtubei.googleapis.com youtube.googleapis.com www.youtube-nocookie.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 $NF}')" + if [ -n "${safe_ips}" ] + then + printf "%s\n" ${safe_domains} > "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" + fi + fi out_rc="${?}" ;; esac - if [ "${out_rc}" -eq 0 ] && [ -f "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" ] + if [ "${out_rc}" -eq 0 ] && [ -s "${adb_tmpdir}/tmp.raw.safesearch.${src_name}" ] then > "${adb_tmpdir}/tmp.safesearch.${src_name}" if [ "${adb_dns}" = "named" ] -- 2.30.2