From 272c79de8398ffbea12fb4e860cc31cc6455dfd6 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Wed, 17 May 2017 21:28:12 +0200 Subject: [PATCH] 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 --- net/adblock/Makefile | 2 +- net/adblock/files/adblock.sh | 75 +++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/net/adblock/Makefile b/net/adblock/Makefile index 0dc19bf29f..91f16c1c4a 100644 --- a/net/adblock/Makefile +++ b/net/adblock/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=adblock -PKG_VERSION:=2.6.3 +PKG_VERSION:=2.6.4 PKG_RELEASE:=1 PKG_LICENSE:=GPL-3.0+ PKG_MAINTAINER:=Dirk Brenken diff --git a/net/adblock/files/adblock.sh b/net/adblock/files/adblock.sh index 2660ce56fd..ade3c73efb 100755 --- a/net/adblock/files/adblock.sh +++ b/net/adblock/files/adblock.sh @@ -10,7 +10,7 @@ # LC_ALL=C 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_enabled=1 adb_debug=0 @@ -21,7 +21,7 @@ adb_backupdir="/mnt" adb_whitelist="/etc/adblock/adblock.whitelist" adb_whitelist_rset="\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}" 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_dnsprefix="adb_list" adb_rtfile="/tmp/adb_runtime.json" @@ -33,7 +33,7 @@ adb_action="${1}" # f_envload() { - local dns_up cnt=0 + local services dns_up cnt=0 # source in system library # @@ -45,37 +45,6 @@ f_envload() f_log "error" "system libraries not found" 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 # config_cb() @@ -94,7 +63,7 @@ f_envload() fi } - # parse 'source' section + # parse 'source' sections # parse_config() { @@ -115,6 +84,40 @@ f_envload() config_load adblock 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}" ] then f_log "error" "no active/supported DNS backend found" @@ -171,7 +174,7 @@ f_envcheck() then if [ "$(readlink -fn "${adb_fetch}")" = "/usr/bin/wget-nossl" ] 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" ] then adb_fetch="/bin/busybox" -- 2.30.2