From 0563feebc69208c85e3a7fa42dc608e67ef57361 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Wed, 23 Dec 2020 21:20:28 +0100 Subject: [PATCH] adblock: backport fixes * set PROCD_RELOAD_DELAY correctly * source changes: - add new source 'games_tracking' (https://www.gameindustry.eu) - change malwaredomains source mirror - remove malwarelist source (source is empty) - remove youtube source (does not work at all) * add check for gnu-sort Signed-off-by: Dirk Brenken --- net/adblock/Makefile | 2 +- net/adblock/files/README.md | 3 +- net/adblock/files/adblock.init | 4 ++- net/adblock/files/adblock.sh | 52 +++++++++++++++++++------------ net/adblock/files/adblock.sources | 23 +++++--------- 5 files changed, 45 insertions(+), 39 deletions(-) diff --git a/net/adblock/Makefile b/net/adblock/Makefile index e6068f7ca..4857d9b7a 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:=3 +PKG_RELEASE:=4 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 6b9f29274..bf6861349 100644 --- a/net/adblock/files/README.md +++ b/net/adblock/files/README.md @@ -24,9 +24,9 @@ A lot of people already use adblocker plugins within their desktop browsers, but | energized_ultimate | | XXL | compilation | [Link](https://energized.pro) | | energized_unified | | XXL | compilation | [Link](https://energized.pro) | | firetv_tracking | | S | tracking | [Link](https://github.com/Perflyst/PiHoleBlocklist) | +| games_tracking | | S | tracking | [Link](https://www.gameindustry.eu) | | gaming | | S | gaming | [Link](https://github.com/abyssin/pihole-blocklist) | | malwaredomains | | M | malware | [Link](https://malwaredomains.com) | -| malwarelist | | S | malware | [Link](https://www.malwaredomainlist.com) | | notracking | | XL | tracking | [Link](https://github.com/notracking/hosts-blocklists) | | oisd_nl | | XXL | general | [Link](https://oisd.nl) | | openphish | | S | phishing | [Link](https://openphish.com) | @@ -59,7 +59,6 @@ A lot of people already use adblocker plugins within their desktop browsers, but | whocares | | M | general | [Link](https://someonewhocares.org) | | winhelp | | S | general | [Link](https://winhelp2002.mvps.org) | | winspy | | S | win_telemetry | [Link](https://github.com/crazy-max/WindowsSpyBlocker) | -| youtube | | M | youtube | [Link](https://github.com/kboghdady/youTube_ads_4_pi-hole) | | yoyo | x | S | general | [Link](https://pgl.yoyo.org/adservers) | * List of supported and fully pre-configured adblock sources, already active sources are pre-selected. diff --git a/net/adblock/files/adblock.init b/net/adblock/files/adblock.init index 64dbd7684..4997b26ee 100755 --- a/net/adblock/files/adblock.init +++ b/net/adblock/files/adblock.init @@ -247,10 +247,12 @@ service_triggers() { local trigger delay type - PROCD_RELOAD_DELAY=$((delay*1000)) trigger="$(uci_get adblock global adb_trigger)" delay="$(uci_get adblock global adb_triggerdelay "2")" type="$(uci_get adblock global adb_starttype "start")" + + PROCD_RELOAD_DELAY=$((delay*1000)) + if [ -n "${trigger}" ] then procd_add_interface_trigger "interface.*.up" "${trigger}" "${adb_init}" "${type}" diff --git a/net/adblock/files/adblock.sh b/net/adblock/files/adblock.sh index 55df0278f..a0c2c0650 100755 --- a/net/adblock/files/adblock.sh +++ b/net/adblock/files/adblock.sh @@ -671,7 +671,7 @@ f_list() rset="/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}" "${adb_awk}" "${rset}" "${adb_blacklist}" | \ "${adb_awk}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' > "${adb_tmpdir}/tmp.raw.${src_name}" - sort ${adb_srtopts} -u "${adb_tmpdir}/tmp.raw.${src_name}" 2>/dev/null > "${adb_tmpfile}.${src_name}" + "${adb_sort}" ${adb_srtopts} -u "${adb_tmpdir}/tmp.raw.${src_name}" 2>/dev/null > "${adb_tmpfile}.${src_name}" out_rc="${?}" rm -f "${adb_tmpdir}/tmp.raw.${src_name}" elif [ "${src_name}" = "whitelist" ] && [ -s "${adb_whitelist}" ] @@ -887,7 +887,7 @@ f_list() find "${adb_backupdir}" ${ffiles} -print0 2>/dev/null | xargs -0 rm 2>/dev/null fi unset src_name - sort ${adb_srtopts} -mu "${adb_tmpfile}".* 2>/dev/null > "${adb_tmpdir}/${adb_dnsfile}" + "${adb_sort}" ${adb_srtopts} -mu "${adb_tmpfile}".* 2>/dev/null > "${adb_tmpdir}/${adb_dnsfile}" out_rc="${?}" rm -f "${adb_tmpfile}".* ;; @@ -1297,7 +1297,7 @@ f_main() "${adb_awk}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' > "${src_tmpsort}" fi rm -f "${src_tmpload}" - sort ${adb_srtopts} -u "${src_tmpsort}" 2>/dev/null > "${src_tmpfile}" + "${adb_sort}" ${adb_srtopts} -u "${src_tmpsort}" 2>/dev/null > "${src_tmpfile}" src_rc="${?}" rm -f "${src_tmpsort}" if [ "${src_rc}" -eq 0 ] && [ -s "${src_tmpfile}" ] @@ -1335,7 +1335,7 @@ f_main() "${adb_awk}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' > "${src_tmpsort}" fi rm -f "${src_tmpload}" - sort ${adb_srtopts} -u "${src_tmpsort}" 2>/dev/null > "${src_tmpfile}" + "${adb_sort}" ${adb_srtopts} -u "${src_tmpsort}" 2>/dev/null > "${src_tmpfile}" src_rc="${?}" rm -f "${src_tmpsort}" if [ "${src_rc}" -eq 0 ] && [ -s "${src_tmpfile}" ] @@ -1499,9 +1499,9 @@ f_report() wait if [ -s "${adb_reportdir}/adb_report.raw" ] then - sort ${adb_srtopts} -k1 -k3 -k4 -k5 -k1 -ur "${adb_reportdir}/adb_report.raw" | \ + "${adb_sort}" ${adb_srtopts} -k1 -k3 -k4 -k5 -k1 -ur "${adb_reportdir}/adb_report.raw" | \ "${adb_awk}" '{currA=($1+0);currB=$1;currC=substr($1,length($1),1);if(reqA==currB){reqA=0;printf "%s\t%s\n",d,$2}else if(currC=="+"){reqA=currA;d=$3"\t"$4"\t"$5"\t"$2}}' | \ - sort ${adb_srtopts} -k1 -k2 -k3 -k4 -ur > "${adb_reportdir}/adb_report.srt" + "${adb_sort}" ${adb_srtopts} -k1 -k2 -k3 -k4 -ur > "${adb_reportdir}/adb_report.srt" rm -f "${adb_reportdir}/adb_report.raw" fi @@ -1528,16 +1528,16 @@ f_report() printf "%s" " \"${top}\": [ " >> "${adb_reportdir}/adb_report.json" case "${top}" in "top_clients") - "${adb_awk}" '{print $3}' "${adb_reportdir}/adb_report.srt" | sort ${adb_srtopts} | uniq -c | \ - sort ${adb_srtopts} -nr | "${adb_awk}" '{ORS=" ";if(NR==1)printf "{ \"count\": \"%s\", \"address\": \"%s\" }",$1,$2; else if(NR<10)printf ", { \"count\": \"%s\", \"address\": \"%s\" }",$1,$2}' >> "${adb_reportdir}/adb_report.json" + "${adb_awk}" '{print $3}' "${adb_reportdir}/adb_report.srt" | "${adb_sort}" ${adb_srtopts} | uniq -c | \ + "${adb_sort}" ${adb_srtopts} -nr | "${adb_awk}" '{ORS=" ";if(NR==1)printf "{ \"count\": \"%s\", \"address\": \"%s\" }",$1,$2; else if(NR<10)printf ", { \"count\": \"%s\", \"address\": \"%s\" }",$1,$2}' >> "${adb_reportdir}/adb_report.json" ;; "top_domains") - "${adb_awk}" '{if($5!="NX")print $4}' "${adb_reportdir}/adb_report.srt" | sort ${adb_srtopts} | uniq -c | \ - sort ${adb_srtopts} -nr | "${adb_awk}" '{ORS=" ";if(NR==1)printf "{ \"count\": \"%s\", \"address\": \"%s\" }",$1,$2; else if(NR<10)printf ", { \"count\": \"%s\", \"address\": \"%s\" }",$1,$2}' >> "${adb_reportdir}/adb_report.json" + "${adb_awk}" '{if($5!="NX")print $4}' "${adb_reportdir}/adb_report.srt" | "${adb_sort}" ${adb_srtopts} | uniq -c | \ + "${adb_sort}" ${adb_srtopts} -nr | "${adb_awk}" '{ORS=" ";if(NR==1)printf "{ \"count\": \"%s\", \"address\": \"%s\" }",$1,$2; else if(NR<10)printf ", { \"count\": \"%s\", \"address\": \"%s\" }",$1,$2}' >> "${adb_reportdir}/adb_report.json" ;; "top_blocked") - "${adb_awk}" '{if($5=="NX")print $4}' "${adb_reportdir}/adb_report.srt" | sort ${adb_srtopts} | uniq -c | \ - sort ${adb_srtopts} -nr | "${adb_awk}" '{ORS=" ";if(NR==1)printf "{ \"count\": \"%s\", \"address\": \"%s\" }",$1,$2; else if(NR<10)printf ", { \"count\": \"%s\", \"address\": \"%s\" }",$1,$2}' >> "${adb_reportdir}/adb_report.json" + "${adb_awk}" '{if($5=="NX")print $4}' "${adb_reportdir}/adb_report.srt" | "${adb_sort}" ${adb_srtopts} | uniq -c | \ + "${adb_sort}" ${adb_srtopts} -nr | "${adb_awk}" '{ORS=" ";if(NR==1)printf "{ \"count\": \"%s\", \"address\": \"%s\" }",$1,$2; else if(NR<10)printf ", { \"count\": \"%s\", \"address\": \"%s\" }",$1,$2}' >> "${adb_reportdir}/adb_report.json" ;; esac printf "%s" " ], " >> "${adb_reportdir}/adb_report.json" @@ -1614,14 +1614,6 @@ f_report() f_log "debug" "f_report ::: action: ${adb_action}, report: ${adb_report}, search: ${1}, count: ${2}, process: ${3}, print: ${4}, dump_util: ${adb_dumpcmd}, repdir: ${adb_reportdir}, repiface: ${adb_repiface:-"-"}, replisten: ${adb_replisten}, repchunksize: ${adb_repchunksize}, repchunkcnt: ${adb_repchunkcnt}, bg_pid: ${bg_pid}" } -# awk selection -# -adb_awk="$(command -v gawk)" -if [ -z "${adb_awk}" ] -then - adb_awk="$(command -v awk)" -fi - # source required system libraries # if [ -r "/lib/functions.sh" ] && [ -r "/lib/functions/network.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ] @@ -1633,6 +1625,26 @@ else f_log "err" "system libraries not found" fi +# awk selection +# +adb_awk="$(command -v gawk)" +if [ -z "${adb_awk}" ] +then + adb_awk="$(command -v awk)" +fi + +# sort selection +# +adb_sort="$(command -v gnu-sort)" +if [ -z "${adb_sort}" ] +then + adb_sort="$(command -v sort)" + if [ -z "$("${adb_sort}" --help 2>/dev/null | grep -Fo -m1 "coreutils")" ] + then + f_log "err" "coreutils sort not found" + fi +fi + # version information # if [ "${adb_action}" = "version" ] diff --git a/net/adblock/files/adblock.sources b/net/adblock/files/adblock.sources index dfb9f1bae..191fa9179 100644 --- a/net/adblock/files/adblock.sources +++ b/net/adblock/files/adblock.sources @@ -97,6 +97,13 @@ "focus": "tracking", "descurl": "https://github.com/Perflyst/PiHoleBlocklist" }, + "games_tracking": { + "url": "https://raw.githubusercontent.com/KodoPengin/GameIndustry-hosts-Template/master/Main%20template/hosts", + "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}", + "size": "S", + "focus": "tracking", + "descurl": "https://www.gameindustry.eu" + }, "gaming": { "url": "https://raw.githubusercontent.com/stopgaming/pihole-blocklist/master/game.txt", "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}", @@ -105,19 +112,12 @@ "descurl": "https://github.com/abyssin/pihole-blocklist" }, "malwaredomains": { - "url": "https://mirror1.malwaredomains.com/files/justdomains", + "url": "https://mirror.cedia.org.ec/malwaredomains/justdomains", "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}", "size": "M", "focus": "malware", "descurl": "https://www.malwaredomains.com" }, - "malwarelist": { - "url": "https://www.malwaredomainlist.com/hostslist/hosts.txt", - "rule": "/^127\\.0\\.0\\.1[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}", - "size": "S", - "focus": "malware", - "descurl": "https://www.malwaredomainlist.com" - }, "notracking": { "url": "https://raw.githubusercontent.com/notracking/hosts-blocklists/master/dnscrypt-proxy/dnscrypt-proxy.blacklist.txt", "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}", @@ -354,13 +354,6 @@ "focus": "win_telemetry", "descurl": "https://github.com/crazy-max/WindowsSpyBlocker" }, - "youtube": { - "url": "https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/black.list", - "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}", - "size": "M", - "focus": "youtube", - "descurl": "https://github.com/kboghdady/youTube_ads_4_pi-hole" - }, "yoyo": { "url": "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext", "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",