lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

commit 564dc2294a3774931bdedc0d86af487bbf3e47a1
parent ba1c55f0af433cfa582e66d1455df5861b994ac9
Author: Dirk Brenken <dev@brenken.org>
Date:   Sun, 11 Sep 2016 18:52:34 +0200

adblock: update 1.4.9

* refine query function (see online doc)

Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat:
Mnet/adblock/Makefile | 2+-
Mnet/adblock/files/README.md | 28+++++++++++++++-------------
Mnet/adblock/files/adblock-update.sh | 2+-
Mnet/adblock/files/adblock.init | 16++++++++++------
4 files changed, 27 insertions(+), 21 deletions(-)

diff --git 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 <dev@brenken.org> diff --git 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:** <pre><code> -/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. </code></pre> **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 @@ -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 @@ -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"