Browse Source

Merge pull request #2049 from dibdot/adblock

adblock: maintenance update
Hannu Nyman 9 years ago
parent
commit
eeb2ccb860

+ 2
- 2
net/adblock/Makefile View File

@@ -7,7 +7,7 @@
7 7
 include $(TOPDIR)/rules.mk
8 8
 
9 9
 PKG_NAME:=adblock
10
-PKG_VERSION:=0.22.1
10
+PKG_VERSION:=0.22.2
11 11
 PKG_RELEASE:=1
12 12
 PKG_LICENSE:=GPL-3.0+
13 13
 PKG_MAINTAINER:=Dirk Brenken <dirk@brenken.org>
@@ -17,7 +17,7 @@ include $(INCLUDE_DIR)/package.mk
17 17
 define Package/$(PKG_NAME)
18 18
 	SECTION:=net
19 19
 	CATEGORY:=Network
20
-	TITLE:=powerful adblock script to block ad/abuse domains
20
+	TITLE:=Powerful adblock script to block ad/abuse domains
21 21
 	DEPENDS:=+curl +wget
22 22
 	PKGARCH:=all
23 23
 endef

+ 27
- 25
net/adblock/files/README.md View File

@@ -12,22 +12,24 @@ and return the local ip address of your router and the internal web server deliv
12 12
 * support of the following domain blacklist sites (free for private usage, for commercial use please check their individual licenses):
13 13
     * [pgl.yoyo.org](http://pgl.yoyo.org/adservers), approx. 2.500 entries
14 14
     * [malwaredomains.com](http://malwaredomains.com), approx. 16.000 entries
15
-    * [zeustracker.abuse.ch](https://zeustracker.abuse.ch), currently down
15
+    * [zeustracker.abuse.ch](https://zeustracker.abuse.ch), approx. 420 entries
16 16
     * [feodotracker.abuse.ch](https://feodotracker.abuse.ch), approx. 10 entries
17 17
     * [palevotracker.abuse.ch](https://palevotracker.abuse.ch), approx. 10 entries
18 18
     * [dshield.org](http://dshield.org), approx. 4.500 entries
19
-    * [shallalist.de](http://www.shallalist.de) (tested with the categories "adv" "costtraps" "downloads" "spyware" "tracker" "warez"), approx. 37.000 entries
19
+    * [shallalist.de](http://www.shallalist.de) (categories "adv" "costtraps" "spyware" "tracker" "warez" enabled by default), approx. 32.000 entries
20
+    * a short description of all shallalist categories can be found [online](http://www.shallalist.de/categories.html)
20 21
     * [spam404.com](http://www.spam404.com), approx. 5.000 entries
21 22
     * [winhelp2002.mvps.org](http://winhelp2002.mvps.org), approx. 15.000 entries
22 23
 * blocklist parsing by fast & flexible regex rulesets
23 24
 * additional white- and blacklist support for manual overrides
24 25
 * separate dynamic adblock network interface
25 26
 * separate dynamic uhttpd instance as pixel server
26
-* optional: quality checks and a powerful backup/restore handling to ensure a reliable dnsmasq service
27
+* adblock quality checks after list update to ensure a reliable dnsmasq service
28
+* optional: powerful adblock list backup/restore handling
27 29
 * optional: adblock updates only on pre-defined wan interfaces (useful for (mobile) multiwan setups)
28
-* optional: domain query logging as a background service to easily identify free and already blocked domains
30
+* optional: domain query logging as a background service to easily identify free and already blocked domains (see example output below)
31
+* optional: status & error logging to separate file (req. ntp time sync)
29 32
 * optional: ntp time sync
30
-* optional: status & error logging (req. ntp time sync)
31 33
 
32 34
 ## Prerequisites
33 35
 * [openwrt](https://openwrt.org) (tested only with trunk > r47025), CC should also work
@@ -41,8 +43,9 @@ and return the local ip address of your router and the internal web server deliv
41 43
 
42 44
 ## Usage
43 45
 * select & install adblock package (*opkg install adblock*)
44
-* configure /etc/config/adblock to your needs, see additional comments in *adblock.conf.sample*
46
+* configure */etc/config/adblock* to your needs, see additional comments in *adblock.conf.sample*
45 47
 * at least configure the ip address of the local adblock interface/uhttpd instance, needs to be a different subnet from the normal LAN
48
+* optional: add additional domain white- or blacklist entries, one domain per line (wildcards & regex are not allowed!), both list are located in */etc/adblock*
46 49
 * by default openwrts main uhttpd instance is bind to all ports of your router. For a working adblock setup you have to bind uhttpd to the standard LAN port only, please change listen_http accordingly
47 50
 * start /usr/bin/adblock-update.sh and check console output or *logread -e "adblock"* for errors
48 51
 
@@ -59,25 +62,24 @@ and return the local ip address of your router and the internal web server deliv
59 62
 
60 63
   stdout excerpt for successful adblock run:  
61 64
     
62
-    root@pi2wrt:~# /usr/bin/adblock-update.sh  
63
-    adblock[17771] info : domain adblock processing started (0.21.0)  
64
-    adblock[17771] info : get wan/update interface (wlan1), after 0 loops  
65
-    adblock[17771] info : get ntp time sync (0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org), after 0 loops  
66
-    adblock[17771] info : shallalist archive download finished  
67
-    adblock[17771] info : shallalist archive extraction finished  
68
-    adblock[17771] info : shallalist (pre-)processing finished (adv costtraps downloads spyware tracker warez)  
69
-    adblock[17771] info : source download finished (http://pgl.yoyo.org/adservers/serverlist.php?hostformat=one-line&showintro=0&mimetype=plaintext, 2426 entries)  
70
-    adblock[17771] info : source download finished (http://mirror1.malwaredomains.com/files/justdomains, 15275 entries)  
71
-    adblock[17771] info : source download finished (https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist, 3 entries)  
72
-    adblock[17771] info : source download finished (https://feodotracker.abuse.ch/blocklist/?download=domainblocklist, 0 entries)  
73
-    adblock[17771] info : source download finished (https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist, 11 entries)  
74
-    adblock[17771] info : source download finished (http://www.dshield.org/feeds/suspiciousdomains_Low.txt, 4542 entries)  
75
-    adblock[17771] info : source download finished (http://spam404bl.com/spam404scamlist.txt, 5193 entries)  
76
-    adblock[17771] info : source download finished (http://winhelp2002.mvps.org/hosts.txt, 13852 entries)  
77
-    adblock[17771] info : source download finished (file:////tmp/tmp.emlDeH/shallalist.txt, 36961 entries)  
78
-    adblock[17771] info : source download finished (file:///etc/adblock/adblock.blacklist, 1 entries)  
79
-    adblock[17771] info : new adblock list with 73090 domains loaded, backup generated  
80
-    adblock[17771] info : domain adblock processing finished (0.21.0)  
65
+    adblock[11541] info : domain adblock processing started (0.22.2, r47665, 29.11.2015 14:58:11)  
66
+    adblock[11541] info : wan update check will be disabled  
67
+    adblock[11541] info : get ntp time sync (192.168.254.254), after 0 loops  
68
+    adblock[11541] info : shallalist (pre-)processing started ...  
69
+    adblock[11541] info : shallalist (pre-)processing finished (adv costtraps spyware tracker warez)  
70
+    adblock[11541] info : source download finished (http://pgl.yoyo.org/adservers/serverlist.php?hostformat=one-line&showintro=0&mimetype=plaintext, 2423 entries)  
71
+    adblock[11541] info : source download finished (http://mirror1.malwaredomains.com/files/justdomains, 16016 entries)  
72
+    adblock[11541] info : source download finished (https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist, 419 entries)  
73
+    adblock[11541] info : source download finished (https://feodotracker.abuse.ch/blocklist/?download=domainblocklist, 0 entries)  
74
+    adblock[11541] info : source download finished (https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist, 12 entries)  
75
+    adblock[11541] info : source download finished (http://www.dshield.org/feeds/suspiciousdomains_Low.txt, 4542 entries)  
76
+    adblock[11541] info : source download finished (http://spam404bl.com/spam404scamlist.txt, 5193 entries)  
77
+    adblock[11541] info : source download finished (http://winhelp2002.mvps.org/hosts.txt, 13635 entries)  
78
+    adblock[11541] info : source download finished (file:////tmp/tmp.CgbMmO/shallalist.txt, 32446 entries)  
79
+    adblock[11541] info : empty source download finished (file:///etc/adblock/adblock.blacklist)  
80
+    adblock[11541] info : domain merging finished  
81
+    adblock[11541] info : new adblock list with 69646 domains loaded, backup generated  
82
+    adblock[11541] info : domain adblock processing finished (0.22.2, r47665, 29.11.2015 14:59:23)  
81 83
     
82 84
 
83 85
   generated domain blocklist for dnsmasq:  

+ 17
- 16
net/adblock/files/adblock-helper.sh View File

@@ -195,7 +195,7 @@ f_envcheck()
195 195
 
196 196
     # check main uhttpd configuration
197 197
     #
198
-    check_uhttpd="$(uci get uhttpd.main.listen_http 2>/dev/null | grep -o "0.0.0.0")"
198
+    check_uhttpd="$(uci get uhttpd.main.listen_http 2>/dev/null | grep -Fo "0.0.0.0")"
199 199
     if [ -n "${check_uhttpd}" ]
200 200
     then
201 201
         rc=530
@@ -287,20 +287,20 @@ f_envcheck()
287 287
     if [ -z "${check}" ]
288 288
     then
289 289
         curl_parm="-q --insecure"
290
-        wget_parm="--no-config --no-check-certificate"
290
+        wget_parm="--no-config --no-hsts --no-check-certificate"
291 291
     else
292 292
         curl_parm="-q"
293
-        wget_parm="--no-config"
293
+        wget_parm="--no-config --no-hsts"
294 294
     fi
295 295
 
296 296
     # check total and swap memory
297 297
     #
298
-    mem_total="$(cat /proc/meminfo | grep "MemTotal" | grep -o "[0-9]*")"
299
-    mem_free="$(cat /proc/meminfo | grep "MemFree" | grep -o "[0-9]*")"
300
-    swap_total="$(cat /proc/meminfo | grep "SwapTotal" | grep -o "[0-9]*")"
298
+    mem_total="$(cat /proc/meminfo | grep -F "MemTotal" | grep -o "[0-9]*")"
299
+    mem_free="$(cat /proc/meminfo | grep -F "MemFree" | grep -o "[0-9]*")"
300
+    swap_total="$(cat /proc/meminfo | grep -F "SwapTotal" | grep -o "[0-9]*")"
301 301
     if [ $((mem_total)) -le 64000 ] && [ $((swap_total)) -eq 0 ]
302 302
     then
303
-        f_log "please consider to add an external swap device to supersize your /tmp directory (total: ${mem_total}, free: ${mem_free}, swap: ${mem_swap})"
303
+        f_log "please consider adding an external swap device to supersize your /tmp directory (total: ${mem_total}, free: ${mem_free}, swap: ${mem_swap})"
304 304
     fi
305 305
 
306 306
     # check backup configuration
@@ -323,7 +323,7 @@ f_envcheck()
323 323
     then
324 324
         # check find capabilities
325 325
         #
326
-        check="$(find --help 2>&1 | grep "mtime")"
326
+        check="$(find --help 2>&1 | grep -F "mtime")"
327 327
         if [ -z "${check}" ]
328 328
         then
329 329
             query_ok="false"
@@ -340,7 +340,7 @@ f_envcheck()
340 340
         if [ -s "${adb_querypid}" ]
341 341
         then
342 342
             kill -9 "$(cat "${adb_querypid}")" >/dev/null 2>&1
343
-            f_log "remove old dns query log background process (pid: $(cat "${adb_querypid}"))"
343
+            f_log "remove old dns query log background process (pid: $(cat "${adb_querypid}" 2>/dev/null))"
344 344
             > "${adb_querypid}"
345 345
         fi
346 346
     fi
@@ -442,11 +442,12 @@ f_log()
442 442
         then
443 443
             class="error"
444 444
             log_rc=", rc: ${log_rc}"
445
+            log_msg="${log_msg}${log_rc}"
445 446
         fi
446
-        /usr/bin/logger -s -t "adblock[${pid}] ${class}" "${log_msg}${log_rc}"
447
+        /usr/bin/logger -s -t "adblock[${pid}] ${class}" "${log_msg}"
447 448
         if [ "${log_ok}" = "true" ] && [ "${ntp_ok}" = "true" ]
448 449
         then
449
-            printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") adblock[${pid}] ${class}: ${log_msg}${log_rc}" >> "${adb_logfile}"
450
+            printf "%s\n" "$(/bin/date "+%d.%m.%Y %H:%M:%S") adblock[${pid}] ${class}: ${log_msg}" >> "${adb_logfile}"
450 451
         fi
451 452
     fi
452 453
 }
@@ -500,7 +501,7 @@ f_deltemp()
500 501
     then
501 502
        rm -rf "${adb_tmpdir}" >/dev/null 2>&1
502 503
     fi
503
-    f_log "domain adblock processing finished (${adb_version}, ${openwrt_version})"
504
+    f_log "domain adblock processing finished (${adb_version}, ${openwrt_version}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))"
504 505
     exit ${rc}
505 506
 }
506 507
 
@@ -516,13 +517,13 @@ f_remove()
516 517
         then
517 518
             kill -9 "$(cat "${adb_querypid}")" >/dev/null 2>&1
518 519
             find "${adb_backupdir}" -maxdepth 1 -type f -mtime +"${adb_queryhistory}" -name "${query_name}.*" -exec rm -f {} \; 2>/dev/null
519
-            f_log "remove old dns query log background process (pid: $(cat "${adb_querypid}")) and do logfile housekeeping"
520
+            f_log "remove old domain query log background process (pid: $(cat "${adb_querypid}")) and do logfile housekeeping"
520 521
             > "${adb_querypid}"
521 522
         fi
522 523
         if [ ! -s "${adb_querypid}" ]
523 524
         then
524
-            ( logread -f 2>/dev/null & printf ${!} > "${adb_querypid}" ) | egrep -o "(query\[A\].*)|([a-z0-9\.\-]* is ${query_ip}$)" >> "${adb_queryfile}.${query_date}" &
525
-            f_log "new domain query log background process started (pid: $(cat "${adb_querypid}"))"
525
+            (logread -f 2>/dev/null & printf ${!} > "${adb_querypid}") | grep -Eo "(query\[A\].*)|([a-z0-9\.\-]* is ${query_ip}$)" >> "${adb_queryfile}.${query_date}" &
526
+            f_log "new domain query log background process started"
526 527
         fi
527 528
     fi
528 529
     f_deltemp
@@ -626,7 +627,7 @@ f_dnscheck()
626 627
     rc=${?}
627 628
     if [ -z "${dns_status}" ]
628 629
     then
629
-        dns_status="$(nslookup "${adb_domain}" 2>/dev/null | grep "${adb_ip}")"
630
+        dns_status="$(nslookup "${adb_domain}" 2>/dev/null | grep -F "${adb_ip}")"
630 631
         rc=${?}
631 632
         if [ -z "${dns_status}" ]
632 633
         then

+ 15
- 15
net/adblock/files/adblock-update.sh View File

@@ -25,7 +25,7 @@
25 25
 
26 26
 # set script version
27 27
 #
28
-adb_version="0.22.1"
28
+adb_version="0.22.2"
29 29
 
30 30
 # get current pid, script directory and openwrt version
31 31
 #
@@ -54,7 +54,7 @@ trap "f_log 'trap error' '600'; f_restore" 1 2 3 10 11 15
54 54
 
55 55
 # start logging
56 56
 #
57
-f_log "domain adblock processing started (${adb_version}, ${openwrt_version})"
57
+f_log "domain adblock processing started (${adb_version}, ${openwrt_version}, $(/bin/date "+%d.%m.%Y %H:%M:%S"))"
58 58
 
59 59
 # load environment
60 60
 #
@@ -74,14 +74,13 @@ if [ -n "${adb_arc_shalla}" ]
74 74
 then
75 75
     # download shallalist archive
76 76
     #
77
+    f_log "shallalist (pre-)processing started ..."
77 78
     shalla_archive="${adb_tmpdir}/shallalist.tar.gz"
78 79
     shalla_file="${adb_tmpdir}/shallalist.txt"
79 80
     curl ${curl_parm} --max-time "${adb_maxtime}" "${adb_arc_shalla}" --output "${shalla_archive}" 2>/dev/null
80 81
     rc=${?}
81
-    if [ $((rc)) -eq 0 ]
82
+    if [ $((rc)) -ne 0 ]
82 83
     then
83
-        f_log "shallalist archive download finished"
84
-    else
85 84
         f_log "shallalist archive download failed (${adb_arc_shalla})" "${rc}"
86 85
         f_restore
87 86
     fi
@@ -91,15 +90,10 @@ then
91 90
     > "${shalla_file}"
92 91
     for category in ${adb_cat_shalla}
93 92
     do
94
-        tar -C "${adb_tmpdir}" -xzf "${shalla_archive}" BL/${category}/domains 2>/dev/null
93
+        tar -xOzf "${shalla_archive}" BL/${category}/domains 2>/dev/null >> "${shalla_file}"
95 94
         rc=${?}
96
-        if [ $((rc)) -eq 0 ]
95
+        if [ $((rc)) -ne 0 ]
97 96
         then
98
-            if [ -r "${adb_tmpdir}/BL/${category}/domains" ]
99
-            then
100
-                cat "${adb_tmpdir}/BL/${category}/domains" 2>/dev/null >> "${shalla_file}"
101
-            fi
102
-        else
103 97
             f_log "shallalist archive extraction failed (${category})" "${rc}"
104 98
             f_restore
105 99
         fi
@@ -157,9 +151,15 @@ done
157 151
 # remove whitelist domains, sort domains and make them unique
158 152
 # and finally rewrite ad/abuse domain information to dnsmasq file
159 153
 #
160
-> "${adb_dnsfile}"
161
-grep -vxf "${adb_whitelist}" < "${adb_tmpfile}" 2>/dev/null | sort -u 2>/dev/null | eval "${adb_dnsformat}" 2>/dev/null >> "${adb_dnsfile}"
162
-rc=${?}
154
+if [ -s "${adb_whitelist}" ]
155
+then
156
+    grep -Fvxf "${adb_whitelist}" "${adb_tmpfile}" 2>/dev/null | sort -u 2>/dev/null | eval "${adb_dnsformat}" 2>/dev/null > "${adb_dnsfile}"
157
+    rc=${?}
158
+else
159
+    sort -u "${adb_tmpfile}" 2>/dev/null | eval "${adb_dnsformat}" 2>/dev/null > "${adb_dnsfile}"
160
+    rc=${?}
161
+fi
162
+
163 163
 if [ $((rc)) -eq 0 ]
164 164
 then
165 165
     rm -f "${adb_tmpfile}" >/dev/null 2>&1

+ 1
- 1
net/adblock/files/adblock.blacklist View File

@@ -1 +1 @@
1
-bild.de
1
+

+ 0
- 1
net/adblock/files/adblock.conf View File

@@ -63,7 +63,6 @@ config source "shalla"
63 63
 	option adb_arc_shalla "http://www.shallalist.de/Downloads/shallalist.tar.gz"
64 64
 	list adb_catlist "adv"
65 65
 	list adb_catlist "costtraps"
66
-	list adb_catlist "downloads"
67 66
 	list adb_catlist "spyware"
68 67
 	list adb_catlist "tracker"
69 68
 	list adb_catlist "warez"

+ 1
- 4
net/adblock/files/adblock.whitelist View File

@@ -1,4 +1 @@
1
-downloads.openwrt.org
2
-ftp.de.debian.org
3
-download.eclipse.org
4
-dl.sourceforge.net
1
+