mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 15:38:40 +01:00
adblock: bugfix 3.8.13
* remove 'ransomware' blocklist by abbuse.ch (discontinued)
from default adblock config
* fix/switch 'someonewhocares' config to https only
* fix curl download parameters to follow redirects and
suppress needless output
* made the tmp directory of sort operations configurable,
set 'adb_sorttmp' accordingly (only supported by 'coreutils-sort')
Signed-off-by: Dirk Brenken <dev@brenken.org>
(cherry picked from commit 21a85fef22)
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#
|
||||
LC_ALL=C
|
||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
adb_ver="3.8.12"
|
||||
adb_ver="3.8.13"
|
||||
adb_basever=""
|
||||
adb_enabled=0
|
||||
adb_debug=0
|
||||
@@ -35,6 +35,7 @@ adb_dnsflush=0
|
||||
adb_blacklist="/etc/adblock/adblock.blacklist"
|
||||
adb_whitelist="/etc/adblock/adblock.whitelist"
|
||||
adb_rtfile="/tmp/adb_runtime.json"
|
||||
adb_sorttmpdir="/tmp"
|
||||
adb_portlist="53 853 5353"
|
||||
adb_report=0
|
||||
adb_repiface="br-lan"
|
||||
@@ -235,6 +236,13 @@ f_env()
|
||||
f_log "err" "backup directory '${adb_backupdir}' does not exist/is not mounted yet, please create the directory or raise the 'adb_triggerdelay' to defer the adblock start"
|
||||
fi
|
||||
|
||||
# check sort temp directory
|
||||
#
|
||||
if [ ! -d "${adb_sorttmpdir}" ]
|
||||
then
|
||||
f_log "err" "sort temp directory '${adb_sorttmpdir}' does not exist/is not mounted yet, please create the directory or raise the 'adb_triggerdelay' to defer the adblock start"
|
||||
fi
|
||||
|
||||
# check fetch utility
|
||||
#
|
||||
case "${adb_fetchutil}" in
|
||||
@@ -258,7 +266,7 @@ f_env()
|
||||
adb_fetchparm="${adb_fetchparm:-"-O"}"
|
||||
;;
|
||||
"curl")
|
||||
adb_fetchparm="${adb_fetchparm:-"--connect-timeout 10 --insecure -o"}"
|
||||
adb_fetchparm="${adb_fetchparm:-"--connect-timeout 10 --silent --show-error --location --insecure -o"}"
|
||||
ssl_lib="built-in"
|
||||
;;
|
||||
"aria2c")
|
||||
@@ -692,7 +700,7 @@ f_tld()
|
||||
awk 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' "${source}" > "${temp_tld}"
|
||||
if [ "${?}" -eq 0 ]
|
||||
then
|
||||
sort -u "${temp_tld}" > "${source}"
|
||||
sort -T "${adb_sorttmpdir}" -u "${temp_tld}" > "${source}"
|
||||
if [ "${?}" -eq 0 ]
|
||||
then
|
||||
cnt_srt="$(wc -l 2>/dev/null < "${source}")"
|
||||
@@ -710,7 +718,7 @@ f_tld()
|
||||
fi
|
||||
fi
|
||||
else
|
||||
sort -u "${source}" > "${temp_tld}"
|
||||
sort -T "${adb_sorttmpdir}" -u "${source}" > "${temp_tld}"
|
||||
if [ "${?}" -eq 0 ]
|
||||
then
|
||||
mv -f "${temp_tld}" "${source}"
|
||||
@@ -960,7 +968,7 @@ f_main()
|
||||
mem_total="$(awk '/^MemTotal/ {print int($2/1000)}' "/proc/meminfo" 2>/dev/null)"
|
||||
mem_free="$(awk '/^MemFree/ {print int($2/1000)}' "/proc/meminfo" 2>/dev/null)"
|
||||
f_log "debug" "f_main ::: dns: ${adb_dns}, fetch_util: ${adb_fetchinfo}, force_dns: ${adb_forcedns}, mem_total: ${mem_total:-0}, mem_free: ${mem_free:-0}, max_queue: ${adb_maxqueue}"
|
||||
|
||||
|
||||
# main loop
|
||||
#
|
||||
f_list blacklist
|
||||
@@ -1179,8 +1187,8 @@ f_report()
|
||||
if [ -s "${adb_repdir}/adb_report.raw" ]
|
||||
then
|
||||
awk '{printf("%s\t%s\t%s\t%s\t%s\t%s\n", $4,$5,$1,$2,$3,$4)}' "${adb_repdir}/adb_report.raw" | \
|
||||
sort -ur | uniq -uf2 | awk '{currA=($6+0);currB=$6;currC=substr($6,length($6),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 -ur > "${adb_repdir}/adb_report"
|
||||
sort -T "${adb_sorttmpdir}" -ur | uniq -uf2 | awk '{currA=($6+0);currB=$6;currC=substr($6,length($6),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 -T "${adb_sorttmpdir}" -ur > "${adb_repdir}/adb_report"
|
||||
fi
|
||||
|
||||
if [ -s "${adb_repdir}/adb_report" ]
|
||||
@@ -1188,9 +1196,9 @@ f_report()
|
||||
total="$(wc -l < "${adb_repdir}/adb_report")"
|
||||
blocked="$(awk '{if($5=="NX")print $4}' "${adb_repdir}/adb_report" | wc -l)"
|
||||
percent="$(awk -v t="${total}" -v b="${blocked}" 'BEGIN{printf("%.2f %s\n",b/t*100, "%")}')"
|
||||
rep_clients="$(awk '{print $3}' "${adb_repdir}/adb_report" | sort | uniq -c | sort -r | awk '{ORS=" ";if(NR<=10) printf("%s_%s ",$1,$2)}')"
|
||||
rep_domains="$(awk '{if($5!="NX")print $4}' "${adb_repdir}/adb_report" | sort | uniq -c | sort -r | awk '{ORS=" ";if(NR<=10)printf("%s_%s ",$1,$2)}')"
|
||||
rep_blocked="$(awk '{if($5=="NX")print $4}' "${adb_repdir}/adb_report" | sort | uniq -c | sort -r | awk '{ORS=" ";if(NR<=10)printf("%s_%s ",$1,$2)}')"
|
||||
rep_clients="$(awk '{print $3}' "${adb_repdir}/adb_report" | sort -T "${adb_sorttmpdir}" | uniq -c | sort -T "${adb_sorttmpdir}" -r | awk '{ORS=" ";if(NR<=10) printf("%s_%s ",$1,$2)}')"
|
||||
rep_domains="$(awk '{if($5!="NX")print $4}' "${adb_repdir}/adb_report" | sort -T "${adb_sorttmpdir}" | uniq -c | sort -T "${adb_sorttmpdir}" -r | awk '{ORS=" ";if(NR<=10)printf("%s_%s ",$1,$2)}')"
|
||||
rep_blocked="$(awk '{if($5=="NX")print $4}' "${adb_repdir}/adb_report" | sort -T "${adb_sorttmpdir}" | uniq -c | sort -T "${adb_sorttmpdir}" -r | awk '{ORS=" ";if(NR<=10)printf("%s_%s ",$1,$2)}')"
|
||||
|
||||
> "${adb_repdir}/adb_report.json"
|
||||
json_load_file "${adb_repdir}/adb_report.json" >/dev/null 2>&1
|
||||
|
||||
Reference in New Issue
Block a user