adblock: update 1.4.7 3096/head
authorDirk Brenken <dev@brenken.org>
Thu, 25 Aug 2016 11:41:15 +0000 (13:41 +0200)
committerDirk Brenken <dev@brenken.org>
Fri, 26 Aug 2016 11:07:53 +0000 (13:07 +0200)
* add a query function to search the active blocklists for a specific
domain (/etc/init.d/adblock query <DOMAIN>)
* fix bug in ap mode/uhttpd port detection
* check general firewall and dnsmasq package dependencies and remove
redundant checks in ap mode

Signed-off-by: Dirk Brenken <dev@brenken.org>
net/adblock/Makefile
net/adblock/files/README.md
net/adblock/files/adblock-helper.sh
net/adblock/files/adblock-update.sh
net/adblock/files/adblock.init

index f95d0ee0c9adedfec0439f9e2566c7d3756d85c5..d7061772e4b22093178391bbc83e81b6e03eac4d 100644 (file)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=adblock
-PKG_VERSION:=1.4.6
+PKG_VERSION:=1.4.7
 PKG_RELEASE:=1
 PKG_LICENSE:=GPL-3.0+
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
index 6b9b0b20675fb0a89a5786441324a6d7240d0162..7ee7d1fbf905fdcb34bac677f6b648e347db4ba4 100644 (file)
@@ -48,7 +48,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but
     * [zeus tracker](https://zeustracker.abuse.ch)
     * => daily updates, approx. 440 entries
 * zero-conf like automatic installation & setup, usually no manual changes needed (i.e. ip address, network devices etc.)
-* supports a wide range of router modes (incl. AP mode), as long as the firewall and the DNS server are enabled & in use
+* supports a wide range of router modes (incl. AP mode), as long as firewall and dnsmasq are installed and in use
 * full IPv4 and IPv6 support
 * each blocklist source will be updated and processed separately
 * timestamp check to download and process only updated adblock list sources
@@ -103,10 +103,11 @@ A lot of people already use adblocker plugins within their desktop browsers, but
 * **list updates:** for a scheduled call of the adblock service add an appropriate crontab entry (see example below)
 * **hotplug fine tuning:** to restrict hotplug support to a certain wan interface or to disable it at all, you can set 'adb\_hotplugif' to an existing interface like 'wan' or to a non-existing 'dummy' interface
 * **new list sources:** you could add new blocklist sources on your own via uci config, all you need is a source url and an awk one-liner (see example below)
-* **AP mode:** in 'AP mode' adblock uses automatically the local router ip as nullip address. To make sure that your LuCI interface will be still accessible, you have to change the local uhttpd instance to ports <> 80/443 (see example below)
+* **AP mode:** in 'AP mode' adblock uses automatically the local router ip as nullip address. To make sure that your LuCI interface will be still accessible, you have to change the local uhttpd instance to ports <> 80/443 (see example below), also make sure that firewall and dnsmasq are installed and running
 * **restricted mode:** to disable flash writes with adblock status information to the adblock config file (used by LuCI frontend), please set 'adb\_restricted' to '1'
 * **adblock toggle:** to quickly switch adblocking 'on' or 'off', simply use _/etc/init.d/adblock toggle_
 * **adblock statistics:** to update only the adblock statistics (without updating the block lists as well), please run _/etc/init.d/adblock stats_
+* **adblock query <DOMAIN>:** to query the active blocklists for a specific domain, please run _/etc/init.d/adblock query <DOMAIN>_
 * **configuration update:** to update an outdated adblock config file with the current default version, please run _/etc/init.d/adblock cfgup_, make your individual changes and start the adblock service again
 * **debugging:** for script debugging please set the 'adb\_debug' variable in the header of _/etc/init.d/adblock_ to '1'
 * **disable active dns probing in windows:** to prevent a possible yellow exclamation mark on your internet connection icon (which wrongly means connected, but no internet), please change the following registry key/value from "1" to "0" _HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\EnableActiveProbing_
@@ -179,16 +180,6 @@ config uhttpd 'main'
     list listen_https '0.0.0.0:445'
 </code></pre>
   
-**example grep for blocked (sub-)domains in adblock source files:**
-<pre><code>
-grep "google-analytics.com" "/tmp/dnsmasq.d/adb_list"*
-
-This will output all matches with corresponding source files:
-  /tmp/dnsmasq.d/adb_list.winhelp:address=/ssl.google-analytics.com/198.18.0.1
-  /tmp/dnsmasq.d/adb_list.winhelp:address=/www.google-analytics.com/198.18.0.1
-  /tmp/dnsmasq.d/adb_list.yoyo:address=/google-analytics.com/198.18.0.1
-</code></pre>
-  
 **example to find blocked domains on certain sites for whitelisting:**
 <pre><code>
 1. the easy way ...
index f43fe312b2f22583fd200c1a51e1b2eb61687c08..9fbf6676a7c51ecc3f204c92007fef0410348821 100644 (file)
@@ -169,22 +169,12 @@ f_envcheck()
     then
         adb_nullipv4="${adb_ipv4}"
         adb_nullipv6="${adb_ipv6}"
-        if [ -n "$(${adb_uci} -q get uhttpd.main.listen_http | grep -Fo "80")" ] ||
-           [ -n "$(${adb_uci} -q get uhttpd.main.listen_https | grep -Fo "443")" ]
+        if [ -n "$(${adb_uci} -q get uhttpd.main.listen_http | grep -o ":80$")" ] ||
+           [ -n "$(${adb_uci} -q get uhttpd.main.listen_https | grep -o ":443$")" ]
         then
             rc=-1
             f_log "AP mode detected, please set local LuCI instance to ports <> 80/443"
             f_exit
-        elif [ ! -f "/etc/init.d/dnsmasq" ]
-        then
-            rc=-1
-            f_log "please enable the local dnsmasq instance to use adblock"
-            f_exit
-        elif [ ! -f "/var/run/fw3.state" ]
-        then
-            rc=-1
-            f_log "please enable the local firewall to use adblock"
-            f_exit
         else
             apmode_ok="true"
         fi
@@ -204,23 +194,25 @@ f_envcheck()
 
     # check general package dependencies
     #
-    f_depend "busybox"
-    f_depend "uci"
-    f_depend "uhttpd"
-    f_depend "iptables"
-    f_depend "kmod-ipt-nat"
+    f_depend "busybox -"
+    f_depend "uci -"
+    f_depend "uhttpd -"
+    f_depend "iptables -"
+    f_depend "kmod-ipt-nat -"
+    f_depend "firewall -"
+    f_depend "dnsmasq*"
 
     # check ipv6 related package dependencies
     #
     if [ -n "${adb_wanif6}" ]
     then
-        f_depend "ip6tables" "true"
+        f_depend "ip6tables -" "true"
         if [ "${package_ok}" = "false" ]
         then
             f_log "package 'ip6tables' not found, IPv6 support will be disabled"
             unset adb_wanif6
         else
-            f_depend "kmod-ipt-nat6" "true"
+            f_depend "kmod-ipt-nat6 -" "true"
             if [ "${package_ok}" = "false" ]
             then
                 f_log "package 'kmod-ipt-nat6' not found, IPv6 support will be disabled"
@@ -231,13 +223,13 @@ f_envcheck()
 
     # check uclient-fetch/wget dependencies
     #
-    f_depend "uclient-fetch" "true"
+    f_depend "uclient-fetch -" "true"
     if [ "${package_ok}" = "true" ]
     then
-        f_depend "libustream-polarssl" "true"
+        f_depend "libustream-polarssl -" "true"
         if [ "${package_ok}" = "false" ]
         then
-            f_depend "libustream-\(mbedtls\|openssl\|cyassl\)" "true"
+            f_depend "libustream-\(mbedtls\|openssl\|cyassl\) -" "true"
             if [ "${package_ok}" = "true" ]
             then
                 adb_fetch="$(which uclient-fetch)"
@@ -248,7 +240,7 @@ f_envcheck()
     fi
     if [ -z "${adb_fetch}" ]
     then
-        f_depend "wget" "true"
+        f_depend "wget -" "true"
         if [ "${package_ok}" = "true" ]
         then
             adb_fetch="$(which wget)"
@@ -263,7 +255,7 @@ f_envcheck()
 
     # check ca-certificate package and set fetch parm accordingly
     #
-    f_depend "ca-certificates" "true"
+    f_depend "ca-certificates -" "true"
     if [ "${package_ok}" = "false" ]
     then
         fetch_parm="${fetch_parm} --no-check-certificate"
@@ -452,7 +444,7 @@ f_depend()
     local check_only="${2}"
     package_ok="true"
 
-    check="$(printf "${pkg_list}" | grep "^${package} -")"
+    check="$(printf "${pkg_list}" | grep "^${package}")"
     if [ "${check_only}" = "true" ] && [ -z "${check}" ]
     then
         package_ok="false"
index b25b981c42dbaf2f283ca1121a12c3933fd06cf7..1136d37f792863de5761f82cc5ddf231c274c684 100755 (executable)
@@ -10,7 +10,7 @@
 #
 adb_pid="${$}"
 adb_pidfile="/var/run/adblock.pid"
-adb_scriptver="1.4.6"
+adb_scriptver="1.4.7"
 adb_mincfgver="2.4"
 adb_scriptdir="${0%/*}"
 if [ -r "${adb_pidfile}" ]
index 15c7d9ee7b9163cb3a9c1b5f3087c4f26a16fcda..b0dc777d04ee997af9f82fa27e9c5f371a8eed99 100755 (executable)
@@ -2,10 +2,11 @@
 #
 
 START=99
-EXTRA_COMMANDS="toggle stats cfgup"
+EXTRA_COMMANDS="toggle stats cfgup query"
 EXTRA_HELP="   toggle  Toggle adblock 'on' or 'off'
        stats   Update adblock statistics
-       cfgup   Update adblock configuration file"
+       cfgup   Update adblock configuration file
+       query   <DOMAIN> Query active blocklists for specific domain"
 
 adb_debug=0
 adb_pid="${$}"
@@ -127,3 +128,15 @@ cfgup()
     fi
     return 0
 }
+
+query()
+{
+    if [ -z "${1}" ]
+    then
+        f_log "no domain query input, please submit a specific search domain"
+    else
+        f_log "results for search domain '${1}':"
+        grep "${1}" "/tmp/dnsmasq.d/adb_list"*
+    fi
+    return 0
+}