diff --git a/net/adblock/Makefile b/net/adblock/Makefile index f4fc48a2c..ef5d4e41b 100644 --- a/net/adblock/Makefile +++ b/net/adblock/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=adblock -PKG_VERSION:=1.1.1 +PKG_VERSION:=1.1.2 PKG_RELEASE:=1 PKG_LICENSE:=GPL-3.0+ PKG_MAINTAINER:=Dirk Brenken diff --git a/net/adblock/files/README.md b/net/adblock/files/README.md index 1cbf8ced1..c3e52caa6 100644 --- a/net/adblock/files/README.md +++ b/net/adblock/files/README.md @@ -147,7 +147,7 @@ This rule removes _all_ domains from the blocklists with this string in it, i.e. photos.daily-deals.analoganalytics.com adblockanalytics.com -**example to add a new blocklist sources:** +**example to add a new blocklist source:**

 1. the easy way ...
 example: https://easylist-downloads.adblockplus.org/rolist+easylist.txt
diff --git a/net/adblock/files/adblock-helper.sh b/net/adblock/files/adblock-helper.sh
index b729fc4e3..5cf6831e6 100644
--- a/net/adblock/files/adblock-helper.sh
+++ b/net/adblock/files/adblock-helper.sh
@@ -6,25 +6,25 @@
 #
 f_envload()
 {
-    # source in openwrt function library
+    # source in system function library
     #
     if [ -r "/lib/functions.sh" ]
     then
         . "/lib/functions.sh"
     else
         rc=110
-        f_log "openwrt function library not found" "${rc}"
+        f_log "system function library not found" "${rc}"
         f_exit
     fi
 
-    # source in openwrt network library
+    # source in system network library
     #
     if [ -r "/lib/functions/network.sh" ]
     then
         . "/lib/functions/network.sh"
     else
         rc=115
-        f_log "openwrt network library not found" "${rc}"
+        f_log "system network library not found" "${rc}"
         f_exit
     fi
 
@@ -89,13 +89,13 @@ f_envload()
         f_exit
     fi
 
-    # get list with all installed openwrt packages
+    # get list with all installed packages
     #
     pkg_list="$(opkg list-installed)"
     if [ -z "${pkg_list}" ]
     then
         rc=120
-        f_log "empty openwrt package list" "${rc}"
+        f_log "empty package list" "${rc}"
         f_exit
     fi
 
@@ -127,8 +127,10 @@ f_envload()
     adb_tmpdir="$(mktemp -p /tmp -d)"
     adb_dnsdir="/tmp/dnsmasq.d"
     adb_dnsprefix="adb_list"
-    adb_fetch="/usr/bin/wget"
-    adb_uci="/sbin/uci"
+    adb_uci="$(which uci)"
+    adb_iptv4="$(which iptables)"
+    adb_iptv6="$(which ip6tables)"
+    adb_fetch="$(which wget-ssl)"
     unset adb_srclist adb_revsrclist adb_errsrclist
 
     # get lan ip addresses
@@ -137,10 +139,15 @@ f_envload()
     network_get_ipaddr6 adb_ipv6 "${adb_lanif}"
     if [ -z "${adb_ipv4}" ] && [ -z "${adb_ipv6}" ]
     then
-        rc=135
+        rc=130
         f_log "no valid IPv4/IPv6 configuration found (${adb_lanif}), please set 'adb_lanif' manually" "${rc}"
         f_exit
     fi
+
+    # get system release level
+    #
+    adb_sysver="$(printf "${pkg_list}" | grep "^base-files -")"
+    adb_sysver="${adb_sysver##*-}"
 }
 
 # f_envcheck: check/set environment prerequisites
@@ -161,6 +168,8 @@ f_envcheck()
 
     # check general package dependencies
     #
+    f_depend "busybox"
+    f_depend "uci"
     f_depend "uhttpd"
     f_depend "wget"
     f_depend "iptables"
@@ -203,7 +212,7 @@ f_envcheck()
         then
             if [ $((av_space)) -le 2000 ]
             then
-                rc=140
+                rc=135
                 f_log "not enough free space in '${adb_tmpdir}' (avail. ${av_space} kb)" "${rc}"
                 f_exit
             else
@@ -211,7 +220,7 @@ f_envcheck()
             fi
         fi
     else
-        rc=145
+        rc=140
         f_log "temp directory not found" "${rc}"
         f_exit
     fi
@@ -262,17 +271,17 @@ f_envcheck()
             adb_dnsformat="awk -v ipv6="${adb_nullipv6}" '{print \"address=/\"\$0\"/\"ipv6}'"
         fi
     else
-        rc=150
+        rc=145
         f_log "please enable the local dns server to use adblock" "${rc}"
         f_exit
     fi
 
     # check running firewall
     #
-    check="$(/usr/sbin/iptables -vnL | grep -F "DROP")"
+    check="$(${adb_iptv4} -vnL | grep -F "DROP")"
     if [ -z "${check}" ]
     then
-        rc=155
+        rc=150
         f_log "please enable the local firewall to use adblock" "${rc}"
         f_exit
     fi
@@ -367,7 +376,7 @@ f_depend()
     check="$(printf "${pkg_list}" | grep "^${package} -")"
     if [ -z "${check}" ]
     then
-        rc=160
+        rc=155
         f_log "package '${package}' not found" "${rc}"
         f_exit
     fi
@@ -377,9 +386,7 @@ f_depend()
 #
 f_firewall()
 {
-    local ipt
-    local iptv4="/usr/sbin/iptables"
-    local iptv6="/usr/sbin/ip6tables"
+    local ipt="${adb_iptv4}"
     local proto="${1}"
     local table="${2}"
     local ctype="${3}"
@@ -387,13 +394,11 @@ f_firewall()
     local notes="${5}"
     local rules="${6}"
 
-    # select appropriate iptables executable
+    # select appropriate iptables executable for IPv6
     #
-    if [ "${proto}" = "IPv4" ]
+    if [ "${proto}" = "IPv6" ]
     then
-        ipt="${iptv4}"
-    else
-        ipt="${iptv6}"
+        ipt="${adb_iptv6}"
     fi
 
     # check whether iptables rule already applied and proceed accordingly
@@ -558,7 +563,7 @@ f_restore()
             f_cntconfig
             f_log "adblock lists with overall ${adb_count} domains loaded"
         else
-            rc=165
+            rc=160
             f_log "dnsmasq restart failed, please check 'logread' output" "${rc}"
         fi
     fi
@@ -571,8 +576,6 @@ f_exit()
 {
     local ipv4_adblock=0
     local ipv6_adblock=0
-    local iptv4="/usr/sbin/iptables"
-    local iptv6="/usr/sbin/ip6tables"
 
     # delete temporary files & directories
     #
@@ -591,27 +594,27 @@ f_exit()
     then
         if [ -n "${adb_wanif4}" ]
         then
-            ipv4_adblock="$(${iptv4} -t nat -vnL | awk '$11 ~ /^adb-nat$/ {sum += $1} END {printf sum}')"
-            ipv4_adblock="$((${ipv4_adblock} + $(${iptv4} -vnL | awk '$11 ~ /^adb-(fwd|out)$/ {sum += $1} END {printf sum}')))"
+            ipv4_adblock="$(${adb_iptv4} -t nat -vnL | awk '$11 ~ /^adb-nat$/ {sum += $1} END {printf sum}')"
+            ipv4_adblock="$((${ipv4_adblock} + $(${adb_iptv4} -vnL | awk '$11 ~ /^adb-(fwd|out)$/ {sum += $1} END {printf sum}')))"
         fi
         if [ -n "${adb_wanif6}" ]
         then
-            ipv6_adblock="$(${iptv6} -t nat -vnL | awk '$10 ~ /^adb-nat$/ {sum += $1} END {printf sum}')"
-            ipv6_adblock="$((${ipv6_adblock} + $(${iptv6} -vnL | awk '$10 ~ /^adb-(fwd|out)$/ {sum += $1} END {printf sum}')))"
+            ipv6_adblock="$(${adb_iptv6} -t nat -vnL | awk '$10 ~ /^adb-nat$/ {sum += $1} END {printf sum}')"
+            ipv6_adblock="$((${ipv6_adblock} + $(${adb_iptv6} -vnL | awk '$10 ~ /^adb-(fwd|out)$/ {sum += $1} END {printf sum}')))"
         fi
         if [ -n "$(${adb_uci} -q changes adblock)" ]
         then
             ${adb_uci} -q commit "adblock"
         fi
         f_log "firewall statistics (IPv4/IPv6): ${ipv4_adblock}/${ipv6_adblock} ad related packets blocked"
-        f_log "domain adblock processing finished successfully (${adb_scriptver}, ${openwrt_version}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))"
+        f_log "domain adblock processing finished successfully (${adb_scriptver}, ${adb_sysver}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))"
     elif [ $((rc)) -gt 0 ]
     then
         if [ -n "$(${adb_uci} -q changes adblock)" ]
         then
             ${adb_uci} -q revert "adblock"
         fi
-        f_log "domain adblock processing failed (${adb_scriptver}, ${openwrt_version}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))"
+        f_log "domain adblock processing failed (${adb_scriptver}, ${adb_sysver}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))"
     else
         rc=0
     fi
diff --git a/net/adblock/files/adblock-update.sh b/net/adblock/files/adblock-update.sh
index fb031dd92..a939f868d 100755
--- a/net/adblock/files/adblock-update.sh
+++ b/net/adblock/files/adblock-update.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-# ad/abuse domain blocking script for dnsmasq/openwrt
+# dns based ad/abuse domain blocking script
 # written by Dirk Brenken (openwrt@brenken.org)
 
 # This is free software, licensed under the GNU General Public License v3.
@@ -33,11 +33,10 @@ else
     printf "${adb_pid}" > "${adb_pidfile}"
 fi
 
-# get current directory, script- and openwrt version
+# get current directory and script version
 #
 adb_scriptdir="${0%/*}"
-adb_scriptver="1.1.1"
-openwrt_version="$(cat /etc/openwrt_version)"
+adb_scriptver="1.1.2"
 
 # source in adblock function library
 #
@@ -61,7 +60,7 @@ f_envload
 
 # start logging
 #
-f_log "domain adblock processing started (${adb_scriptver}, ${openwrt_version}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))"
+f_log "domain adblock processing started (${adb_scriptver}, ${adb_sysver}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))"
 
 # check environment
 #