Browse Source

adblock: maintenance update 2.6.4

* made wget default parms compatible with older program versions
* shift dns detection routine to simplify dns override,
  just set 'adb_dnslist' to force a particular backend priority
  (default: 'dnsmasq unbound')
* reduce ubus polling during dns detection

Signed-off-by: Dirk Brenken <dev@brenken.org>
lilik-openwrt-22.03
Dirk Brenken 8 years ago
parent
commit
272c79de83
2 changed files with 40 additions and 37 deletions
  1. +1
    -1
      net/adblock/Makefile
  2. +39
    -36
      net/adblock/files/adblock.sh

+ 1
- 1
net/adblock/Makefile View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=adblock PKG_NAME:=adblock
PKG_VERSION:=2.6.3
PKG_VERSION:=2.6.4
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0+ PKG_LICENSE:=GPL-3.0+
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org> PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>


+ 39
- 36
net/adblock/files/adblock.sh View File

@ -10,7 +10,7 @@
# #
LC_ALL=C LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin" PATH="/usr/sbin:/usr/bin:/sbin:/bin"
adb_ver="2.6.3"
adb_ver="2.6.4"
adb_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')" adb_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
adb_enabled=1 adb_enabled=1
adb_debug=0 adb_debug=0
@ -21,7 +21,7 @@ adb_backupdir="/mnt"
adb_whitelist="/etc/adblock/adblock.whitelist" adb_whitelist="/etc/adblock/adblock.whitelist"
adb_whitelist_rset="\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}" adb_whitelist_rset="\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}"
adb_fetch="/usr/bin/wget" adb_fetch="/usr/bin/wget"
adb_fetchparm="--no-config --quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 --no-check-certificate -O"
adb_fetchparm="--quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 --no-check-certificate -O"
adb_dnslist="dnsmasq unbound" adb_dnslist="dnsmasq unbound"
adb_dnsprefix="adb_list" adb_dnsprefix="adb_list"
adb_rtfile="/tmp/adb_runtime.json" adb_rtfile="/tmp/adb_runtime.json"
@ -33,7 +33,7 @@ adb_action="${1}"
# #
f_envload() f_envload()
{ {
local dns_up cnt=0
local services dns_up cnt=0
# source in system library # source in system library
# #
@ -45,37 +45,6 @@ f_envload()
f_log "error" "system libraries not found" f_log "error" "system libraries not found"
fi fi
# set dns backend environment
#
while [ ${cnt} -le 20 ]
do
for dns in ${adb_dnslist}
do
dns_up="$(ubus -S call service list "{\"name\":\"${dns}\"}" | jsonfilter -l1 -e "@.${dns}.instances.*.running")"
if [ "${dns_up}" = "true" ]
then
case "${dns}" in
dnsmasq)
adb_dns="dnsmasq"
adb_dnsdir="/tmp/dnsmasq.d"
adb_dnshidedir="${adb_dnsdir}/.adb_hidden"
adb_dnsformat="awk '{print \"local=/\"\$0\"/\"}'"
break 2
;;
unbound)
adb_dns="unbound"
adb_dnsdir="/var/lib/unbound"
adb_dnshidedir="${adb_dnsdir}/.adb_hidden"
adb_dnsformat="awk '{print \"local-zone: \042\"\$0\"\042 static\"}'"
break 2
;;
esac
fi
done
sleep 1
cnt=$((cnt+1))
done
# parse global section by callback # parse global section by callback
# #
config_cb() config_cb()
@ -94,7 +63,7 @@ f_envload()
fi fi
} }
# parse 'source' section
# parse 'source' sections
# #
parse_config() parse_config()
{ {
@ -115,6 +84,40 @@ f_envload()
config_load adblock config_load adblock
config_foreach parse_config source config_foreach parse_config source
# set dns backend environment
#
while [ ${cnt} -le 20 ]
do
services="$(ubus -S call service list 2>/dev/null)"
if [ -n "${services}" ]
then
for dns in ${adb_dnslist}
do
dns_up="$(printf "%s" "${services}" | jsonfilter -l1 -e "@.${dns}.instances.*.running")"
if [ "${dns_up}" = "true" ]
then
case "${dns}" in
dnsmasq)
adb_dns="${dns}"
adb_dnsdir="${adb_dnsdir:="/tmp/dnsmasq.d"}"
adb_dnshidedir="${adb_dnsdir}/.adb_hidden"
adb_dnsformat="awk '{print \"local=/\"\$0\"/\"}'"
break 2
;;
unbound)
adb_dns="${dns}"
adb_dnsdir="${adb_dnsdir:="/var/lib/unbound"}"
adb_dnshidedir="${adb_dnsdir}/.adb_hidden"
adb_dnsformat="awk '{print \"local-zone: \042\"\$0\"\042 static\"}'"
break 2
;;
esac
fi
done
fi
sleep 1
cnt=$((cnt+1))
done
if [ -z "${adb_dns}" ] || [ -z "${adb_dnsformat}" ] || [ ! -x "$(command -v ${adb_dns})" ] || [ ! -d "${adb_dnsdir}" ] if [ -z "${adb_dns}" ] || [ -z "${adb_dnsformat}" ] || [ ! -x "$(command -v ${adb_dns})" ] || [ ! -d "${adb_dnsdir}" ]
then then
f_log "error" "no active/supported DNS backend found" f_log "error" "no active/supported DNS backend found"
@ -171,7 +174,7 @@ f_envcheck()
then then
if [ "$(readlink -fn "${adb_fetch}")" = "/usr/bin/wget-nossl" ] if [ "$(readlink -fn "${adb_fetch}")" = "/usr/bin/wget-nossl" ]
then then
adb_fetchparm="--no-config --quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 -O"
adb_fetchparm="--quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 -O"
elif [ "$(readlink -fn "/bin/wget")" = "/bin/busybox" ] || [ "$(readlink -fn "${adb_fetch}")" = "/bin/busybox" ] elif [ "$(readlink -fn "/bin/wget")" = "/bin/busybox" ] || [ "$(readlink -fn "${adb_fetch}")" = "/bin/busybox" ]
then then
adb_fetch="/bin/busybox" adb_fetch="/bin/busybox"


Loading…
Cancel
Save