adblock: update 2.0.3 3716/head
authorDirk Brenken <dev@brenken.org>
Fri, 30 Dec 2016 21:21:00 +0000 (22:21 +0100)
committerDirk Brenken <dev@brenken.org>
Fri, 30 Dec 2016 21:21:00 +0000 (22:21 +0100)
* fixed adblock statistics in CC
* print additional list details in adblock statistics

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

index 8ec995808458a66b370b89d73cb132b9ba598d81..82636ff6add667130c164b41aefe1011febdef8c 100644 (file)
@@ -6,7 +6,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=adblock
-PKG_VERSION:=2.0.2
+PKG_VERSION:=2.0.3
 PKG_RELEASE:=1
 PKG_LICENSE:=GPL-3.0+
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
index a5ecd8a13dd37a130d1b5368a3f55ae50bcdf6e4..569dab2fd27e482406290e70f489d9d1059c0c73 100644 (file)
@@ -144,8 +144,31 @@ config for curl (download errors with default ssl backend!):
   
 **example to receive adblock statistics via ubus:**
 <pre><code>
-ubus call service list '{"name":"adblock_stats"}' | jsonfilter -e '@.*.instances.stats.env'
-This will output the overall domain count and the last runtime as JSON, i.e. { "blocked_domains": "136159", "last_rundate": "18.12.2016 20:49:03" }
+ubus call service list '{"name":"adblock_stats"}'
+This will output the active block lists, the overall domain count and the last runtime as JSON, i.e.:
+{
+    "adblock_stats": {
+        "instances": {
+            "stats": {
+                "running": false,
+                "command": [
+                    ""
+                ],
+                "data": {
+                    "active_lists": [
+                        {
+                            "adaway": "409",
+                            "yoyo": "2368",
+                            "disconnect": "3198"
+                        }
+                    ],
+                    "blocked_domains": "5975",
+                    "last_rundate": "30.12.2016 21:03:45"
+                }
+            }
+        }
+    }
+}
 </code></pre>
   
 **example cronjob for a regular block list update (/etc/crontabs/root):**
index 9bd31f7e7ecc1dff1a7893a30944952b4955dae7..9a8cb2828711e749176400e9931d2c84c9061053 100755 (executable)
@@ -10,7 +10,7 @@
 #
 LC_ALL=C
 PATH="/usr/sbin:/usr/bin:/sbin:/bin"
-adb_ver="2.0.2"
+adb_ver="2.0.3"
 adb_enabled=1
 adb_debug=0
 adb_whitelist="/etc/adblock/adblock.whitelist"
@@ -147,7 +147,7 @@ f_rmdns()
     rm -f "${adb_dnsdir}/${adb_dnsprefix}"*
     rm -f "${adb_dir_backup}/${adb_dnsprefix}"*.gz
     rm -rf "${adb_dnshidedir}"
-    ubus call service delete "{\"name\":\"adblock_stats\",\"instances\":\"stats\"}"
+    ubus call service delete "{\"name\":\"adblock_stats\",\"instances\":\"stats\"}" 2>/dev/null
 }
 
 # f_dnsrestart: restart the dns server
@@ -420,6 +420,13 @@ f_main()
         cat "${src_name}" >> "${adb_tmpdir}/blocklist.overall"
         cnt="$(wc -l < "${src_name}")"
         sum_cnt=$((sum_cnt + cnt))
+        list="${src_name/*./}"
+        if [ -z "${sum_list}" ]
+        then
+            sum_list="\"${list}\":\"${cnt}\""
+        else
+            sum_list="${sum_list},\"${list}\":\"${cnt}\""
+        fi
     done
     f_dnsrestart
     if [ "${dns_running}" = "true" ]
@@ -427,7 +434,11 @@ f_main()
         f_debug
         f_rmtemp
         f_log "info " "status ::: block lists with overall ${sum_cnt} domains loaded (${adb_sysver})"
-        ubus call service set "{\"name\":\"adblock_stats\",\"instances\":{\"stats\":{\"env\":{\"blocked_domains\":\"${sum_cnt}\",\"last_rundate\":\"$(/bin/date "+%d.%m.%Y %H:%M:%S")\"}}}}"
+        ubus call service add "{\"name\":\"adblock_stats\",
+                                \"instances\":{\"stats\":{\"command\":[\"\"],
+                                \"data\":{\"blocked_domains\":\"${sum_cnt}\",
+                                \"last_rundate\":\"$(/bin/date "+%d.%m.%Y %H:%M:%S")\",
+                                \"active_lists\":[{${sum_list}}]}}}}"
         exit 0
     fi
     f_log "error" "status ::: dns server restart with active block lists failed"