adblock: maintenance update 2.6.4 4367/head
authorDirk Brenken <dev@brenken.org>
Wed, 17 May 2017 19:28:12 +0000 (21:28 +0200)
committerDirk Brenken <dev@brenken.org>
Wed, 17 May 2017 19:28:12 +0000 (21:28 +0200)
* 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>
net/adblock/Makefile
net/adblock/files/adblock.sh

index 0dc19bf29f5e71c8472d763d2330d8889fe0c84c..91f16c1c4a7bcc0f2e453003ca8134d6a9e2ef90 100644 (file)
@@ -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 <dev@brenken.org>
index 2660ce56fd0a666415b3f6ebcbc70d696849f6b4..ade3c73efbf6a07cc9d3320951d9282de50eb117 100755 (executable)
@@ -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"