Browse Source

adblock: update to 4.1.2

* preserve DNS cache after adblock processing (unbound & bind)
* fix redirect issue with oisd basic url
* cosmetics

Signed-off-by: Dirk Brenken <dev@brenken.org>
lilik-openwrt-22.03
Dirk Brenken 4 years ago
parent
commit
df8651255f
No known key found for this signature in database GPG Key ID: 9D71CD547BFAE684
4 changed files with 89 additions and 36 deletions
  1. +1
    -1
      net/adblock/Makefile
  2. +5
    -3
      net/adblock/files/README.md
  3. +81
    -30
      net/adblock/files/adblock.sh
  4. +2
    -2
      net/adblock/files/adblock.sources

+ 1
- 1
net/adblock/Makefile View 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>


+ 5
- 3
net/adblock/files/README.md View 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:


+ 81
- 30
net/adblock/files/adblock.sh View File

@ -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


+ 2
- 2
net/adblock/files/adblock.sources View 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",
@ -312,6 +312,6 @@
"rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
"size": "S",
"focus": "general",
"descurl": "https://pgl.yoyo.org"
"descurl": "https://pgl.yoyo.org/as"
}
}

Loading…
Cancel
Save