From 564dc2294a3774931bdedc0d86af487bbf3e47a1 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Sun, 11 Sep 2016 18:52:34 +0200 Subject: [PATCH] adblock: update 1.4.9 * refine query function (see online doc) Signed-off-by: Dirk Brenken --- net/adblock/Makefile | 2 +- net/adblock/files/README.md | 28 +++++++++++++++------------- net/adblock/files/adblock-update.sh | 2 +- net/adblock/files/adblock.init | 16 ++++++++++------ 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/net/adblock/Makefile b/net/adblock/Makefile index 04cabbc30c..d79bf5199d 100644 --- a/net/adblock/Makefile +++ b/net/adblock/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=adblock -PKG_VERSION:=1.4.8 +PKG_VERSION:=1.4.9 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 29a962f6a7..e3b1972697 100644 --- a/net/adblock/files/README.md +++ b/net/adblock/files/README.md @@ -185,21 +185,23 @@ config uhttpd 'main' **example to query active blocklists for a certain (sub-)domain, i.e. for whitelisting:**

-/etc/init.d/adblock query "www.example.ad.where.com"
-=> results for (sub-)domain 'www.example.ad.where.com'
+/etc/init.d/adblock query "example.www.doubleclick.net"
+=> distinct results for domain 'example.www.doubleclick.net' (overall 0)
    no matches in active blocklists
-=> results for (sub-)domain 'example.ad.where.com'
-   no matches in active blocklists
-=> results for (sub-)domain 'ad.where.com'
-   /tmp/dnsmasq.d/adb_list.adaway:15:address=/ad.where.com/192.168.254.250
-=> results for (sub-)domain 'where.com'
-   /tmp/dnsmasq.d/adb_list.adaway:15:address=/ad.where.com/192.168.254.250
-   /tmp/dnsmasq.d/adb_list.hphosts:30264:address=/upstream.where.com/192.168.254.250
-   /tmp/dnsmasq.d/adb_list.securemecca:4503:address=/paypal.adtag.where.com/192.168.254.250
+=> distinct results for domain 'www.doubleclick.net' (overall 1)
+   adb_list.winhelp     : www.doubleclick.net
+=> distinct results for domain 'doubleclick.net' (overall 252)
+   adb_list.adaway      : ad-g.doubleclick.net
+   adb_list.hphosts     : 1016557.fls.doubleclick.net
+   adb_list.rolist      : feedads.g.doubleclick.net
+   adb_list.securemecca : 1168945.fls.doubleclick.net
+   adb_list.sysctl      : ad.co.doubleclick.net
+   adb_list.whocares    : 3ad.doubleclick.net
+   adb_list.winhelp     : 1435575.fls.doubleclick.net
 
-The query function checks against the submitted (sub-)domain and recurse automatically to the (upper) top level domain.
-In the example above you have to whitelist "ad.where.com" to free the submitted (sub-)domain.
-For all matches (max. 3 per list) the query function returns the blocklist name, the line no. and the relevant (sub-)domain/host.
+The query function checks against the submitted (sub-)domain and recurses automatically to the upper top level domain(s).
+For every domain it returns the overall count plus a distinct list of active blocklists with the first relevant result.
+In the example above you have to whitelist "www.doubleclick.net" to free the submitted domain.
 
**example to identify blocked domains during web browsing, i.e. for whitelisting:** diff --git a/net/adblock/files/adblock-update.sh b/net/adblock/files/adblock-update.sh index 2aa0c03d5c..c1e467d7c2 100755 --- a/net/adblock/files/adblock-update.sh +++ b/net/adblock/files/adblock-update.sh @@ -10,7 +10,7 @@ # adb_pid="${$}" adb_pidfile="/var/run/adblock.pid" -adb_scriptver="1.4.8" +adb_scriptver="1.4.9" adb_mincfgver="2.5" adb_scriptdir="${0%/*}" if [ -r "${adb_pidfile}" ] diff --git a/net/adblock/files/adblock.init b/net/adblock/files/adblock.init index c8cf805d4a..f7b707a21b 100755 --- a/net/adblock/files/adblock.init +++ b/net/adblock/files/adblock.init @@ -131,18 +131,22 @@ cfgup() query() { - local search - local domain="${1}" - local tld="${domain#*.}" - if [ -z "${domain}" ] || [ "${domain}" = "${tld}" ] + domain="${1}" + tld="${domain#*.}" + list_dns="$(find "${adb_dnsdir}" -maxdepth 1 -type f -name "${adb_dnsprefix}*" -print)" + if [ -z "${list_dns}" ] + then + f_log "no active blocklists found, please start adblock first" + elif [ -z "${domain}" ] || [ "${domain}" = "${tld}" ] then f_log "invalid domain query input, please submit a specific (sub-)domain, i.e. 'www.abc.xyz'" else while [ "${domain}" != "${tld}" ] do search="${domain//./\.}" - result="$(grep -Hnm 3 "[/\.]${search}/" "/tmp/dnsmasq.d/adb_list"* | sed -e 's/^/ /')" - printf "%s\n" "=> results for (sub-)domain '${domain}'" + result="$(grep -Hm 1 "[/\.]${search}/" "${adb_dnsdir}/adb_list"* | awk -F ':|/' '{print " "$4"\t: "$6}')" + count="$(grep -hc "[/\.]${search}/" "${adb_dnsdir}/adb_list"* | awk '{sum += $1} END {printf sum}')" + printf "%s\n" "=> distinct results for domain '${domain}' (overall ${count})" if [ -z "${result}" ] then printf "%s\n" " no matches in active blocklists" -- 2.30.2