Browse Source

Merge pull request #3901 from dibdot/adblock

adblock: update 2.1.5
lilik-openwrt-22.03
Hannu Nyman 8 years ago
committed by GitHub
parent
commit
372dfaacbf
4 changed files with 38 additions and 27 deletions
  1. +1
    -1
      net/adblock/Makefile
  2. +19
    -14
      net/adblock/files/README.md
  3. +2
    -2
      net/adblock/files/adblock.init
  4. +16
    -10
      net/adblock/files/adblock.sh

+ 1
- 1
net/adblock/Makefile View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=adblock PKG_NAME:=adblock
PKG_VERSION:=2.1.2
PKG_VERSION:=2.1.5
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0+ PKG_LICENSE:=GPL-3.0+
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org> PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>


+ 19
- 14
net/adblock/files/README.md View File

@ -64,7 +64,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* procd based hotplug support, the adblock start will be triggered by interface triggers * procd based hotplug support, the adblock start will be triggered by interface triggers
* suspend & resume adblock actions temporarily without block list reloading * suspend & resume adblock actions temporarily without block list reloading
* runtime statistics via ubus service call * runtime statistics via ubus service call
* query function to quickly identify blocked (sub-)domains, i.e. for whitelisting
* query function to quickly identify blocked (sub-)domains, e.g. for whitelisting
* automatic block list backup & restore, backups will be (de-)compressed and restored on the fly * automatic block list backup & restore, backups will be (de-)compressed and restored on the fly
* add new adblock sources on your own via uci config * add new adblock sources on your own via uci config
@ -72,7 +72,10 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* [openwrt](https://openwrt.org), tested with latest stable release (Chaos Calmer) and with current trunk (Designated Driver) * [openwrt](https://openwrt.org), tested with latest stable release (Chaos Calmer) and with current trunk (Designated Driver)
* [LEDE project](https://www.lede-project.org), tested with trunk > r98 * [LEDE project](https://www.lede-project.org), tested with trunk > r98
* a usual setup with an enabled dns server at minimum - dump AP modes without a working dns server are _not_ supported * a usual setup with an enabled dns server at minimum - dump AP modes without a working dns server are _not_ supported
* a download utility: 'wget', 'aria2c', 'uclient-fetch' or 'curl' are supported (only full versions with ssl support). Normally you should use the pre-configured default 'wget'. If you need a smaller memory footprint try 'uclient-fetch' without openssl dependency.
* a download utility: full versions (with ssl support) of 'wget', 'uclient-fetch', 'aria2c' or 'curl' are supported - the Chaos Calmer built-in busybox wget is not
* Chaos Calmer: download & install the external 'wget' package
* Designated Driver/Trunk: use built-in 'uclient-fetch' or download & install the external 'wget' package
* for more configuration options see examples below
## OpenWrt / LEDE trunk Installation & Usage ## OpenWrt / LEDE trunk Installation & Usage
* install 'adblock' (_opkg install adblock_) and that's it - the adblock start will be automatically triggered by procd interface triggers * install 'adblock' (_opkg install adblock_) and that's it - the adblock start will be automatically triggered by procd interface triggers
@ -98,7 +101,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* **debug output:** for script debugging please set the config option 'adb\_debug' to '1' and check the runtime output with _logread -e "adblock"_ * **debug output:** for script debugging please set the config option 'adb\_debug' to '1' and check the runtime output with _logread -e "adblock"_
* **storage expansion:** to process and store all block list sources at once it might helpful to enlarge your temp directory with a swap partition => see [openwrt wiki](https://wiki.openwrt.org/doc/uci/fstab) for further details * **storage expansion:** to process and store all block list sources at once it might helpful to enlarge your temp directory with a swap partition => see [openwrt wiki](https://wiki.openwrt.org/doc/uci/fstab) for further details
* **add white-/blacklist entries:** add domain white- or blacklist entries to always-allow or -deny certain (sub) domains, by default both lists are empty and located in _/etc/adblock_. Please add one domain per line - ip addresses, wildcards & regex are _not_ allowed (see example below) * **add white-/blacklist entries:** add domain white- or blacklist entries to always-allow or -deny certain (sub) domains, by default both lists are empty and located in _/etc/adblock_. Please add one domain per line - ip addresses, wildcards & regex are _not_ allowed (see example below)
* **backup & restore block lists:** enable this feature, to restore automatically the latest compressed backup of your block lists in case of any processing error (i.e. a single block list source is not available during update). Please use an (external) solid partition and _not_ your volatile router temp directory for this
* **backup & restore block lists:** enable this feature, to restore automatically the latest compressed backup of your block lists in case of any processing error (e.g. a single block list source is not available during update). Please use an (external) solid partition and _not_ your volatile router temp directory for this
* **scheduled list updates:** for a scheduled call of the adblock service add an appropriate crontab entry (see example below) * **scheduled list updates:** for a scheduled call of the adblock service add an appropriate crontab entry (see example below)
* **restrict/disable procd interface trigger:** to restrict the procd interface trigger to a (list of) certain wan interface(s) or to disable it at all, set 'adb\_iface' to an existing interface like 'wan' or to a non-existing like 'false' * **restrict/disable procd interface trigger:** to restrict the procd interface trigger to a (list of) certain wan interface(s) or to disable it at all, set 'adb\_iface' to an existing interface like 'wan' or to a non-existing like 'false'
* **suspend & resume adblocking:** to quickly switch the adblock service 'on' or 'off', simply use _/etc/init.d/adblock [suspend|resume]_ * **suspend & resume adblocking:** to quickly switch the adblock service 'on' or 'off', simply use _/etc/init.d/adblock [suspend|resume]_
@ -143,7 +146,7 @@ aria2c:
option adb_fetch '/usr/bin/aria2c' option adb_fetch '/usr/bin/aria2c'
option adb_fetchparm '-q --max-tries=1 --timeout=5 --allow-overwrite=true --auto-file-renaming=false --check-certificate=false -o' option adb_fetchparm '-q --max-tries=1 --timeout=5 --allow-overwrite=true --auto-file-renaming=false --check-certificate=false -o'
uclient-fetch:
uclient-fetch (not supported in Chaos Calmer):
option adb_fetch '/bin/uclient-fetch' option adb_fetch '/bin/uclient-fetch'
option adb_fetchparm '-q --timeout=5 --no-check-certificate -O' option adb_fetchparm '-q --timeout=5 --no-check-certificate -O'
@ -155,7 +158,7 @@ curl:
**receive adblock statistics via ubus:** **receive adblock statistics via ubus:**
<pre><code> <pre><code>
ubus call service list '{"name":"adblock_stats"}' ubus call service list '{"name":"adblock_stats"}'
This will output the active block lists and other runtime information as JSON, i.e.:
This will output the active block lists and other runtime information as JSON, e.g.:
{ {
"adblock_stats": { "adblock_stats": {
"instances": { "instances": {
@ -216,16 +219,18 @@ This entry does not remove:
www.adwhere.com www.adwhere.com
</code></pre> </code></pre>
**query active block lists for a certain (sub-)domain, i.e. for whitelisting:**
**query active block lists for a certain (sub-)domain, e.g. for whitelisting:**
<pre><code> <pre><code>
/etc/init.d/adblock query "example.www.doubleclick.net"
:: distinct results for domain 'example.www.doubleclick.net' (overall 0)
no matches in active block lists
:: distinct results for domain 'www.doubleclick.net' (overall 1)
adb_list.securemecca : www.doubleclick.net
:: distinct results for domain 'doubleclick.net' (overall 127)
adb_list.adaway : ad-g.doubleclick.net
adb_list.securemecca : 1168945.fls.doubleclick.net
/etc/init.d/adblock query example.www.doubleclick.net
::: distinct results for domain 'example.www.doubleclick.net'
no match
::: distinct results for domain 'www.doubleclick.net'
adb_list.sysctl : www.doubleclick.net
::: distinct results for domain 'doubleclick.net'
adb_list.adaway : ad-g.doubleclick.net
adb_list.securemecca : 1168945.fls.doubleclick.net
adb_list.sysctl : 1435575.fls.doubleclick.net
adb_list.whocares : 3ad.doubleclick.net
The query function checks against the submitted (sub-)domain and recurses automatically to the upper top level domain(s). 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 block lists with the first relevant result. For every domain it returns the overall count plus a distinct list of active block lists with the first relevant result.


+ 2
- 2
net/adblock/files/adblock.init View File

@ -24,10 +24,10 @@ boot()
if [ -n "${wanif4}" ] || [ -n "${wanif6}" ] if [ -n "${wanif4}" ] || [ -n "${wanif6}" ]
then then
rc_procd start_service rc_procd start_service
else
rc_procd service_triggers
return 0
fi fi
fi fi
rc_procd service_triggers
} }
start_service() start_service()


+ 16
- 10
net/adblock/files/adblock.sh View File

@ -10,7 +10,7 @@
# #
LC_ALL=C LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin" PATH="/usr/sbin:/usr/bin:/sbin:/bin"
adb_ver="2.1.2"
adb_ver="2.1.5"
adb_enabled=1 adb_enabled=1
adb_debug=0 adb_debug=0
adb_whitelist="/etc/adblock/adblock.whitelist" adb_whitelist="/etc/adblock/adblock.whitelist"
@ -31,7 +31,7 @@ f_envload()
f_log "error" "status ::: system library not found" f_log "error" "status ::: system library not found"
fi fi
# set dns server environment
# set dns backend environment
# #
adb_dns="$(uci -q get adblock.global.adb_dns)" adb_dns="$(uci -q get adblock.global.adb_dns)"
if [ "${adb_dns}" = "unbound" ] if [ "${adb_dns}" = "unbound" ]
@ -109,9 +109,14 @@ f_envcheck()
# check fetch utility # check fetch utility
# #
if [ -z "${adb_fetch}" ] || [ ! -f "${adb_fetch}" ]
if [ -z "${adb_fetch}" ] || [ -z "${adb_fetchparm}" ] || [ ! -f "${adb_fetch}" ] || [ "$(readlink -fn "${adb_fetch}")" = "/bin/busybox" ]
then then
f_log "error" "status ::: no download utility with ssl support found/configured"
f_log "error" "status ::: required download utility with ssl support not found, e.g. install full 'wget' package"
fi
if [ "${adb_fetch}" = "/usr/bin/wget" ] && [ "$(readlink -fn "${adb_fetch}")" = "/bin/uclient-fetch" ]
then
adb_fetch="/bin/uclient-fetch"
adb_fetchparm="-q --timeout=5 --no-check-certificate -O"
fi fi
# create dns hideout directory # create dns hideout directory
@ -119,7 +124,7 @@ f_envcheck()
if [ ! -d "${adb_dnshidedir}" ] if [ ! -d "${adb_dnshidedir}" ]
then then
mkdir -p -m 660 "${adb_dnshidedir}" mkdir -p -m 660 "${adb_dnshidedir}"
chown -R "${adb_dns}":"${adb_dns}" "${adb_dnshidedir}"
chown -R "${adb_dns}":"${adb_dns}" "${adb_dnshidedir}" 2>/dev/null
else else
rm -f "${adb_dnshidedir}/${adb_dnsprefix}"* rm -f "${adb_dnshidedir}/${adb_dnsprefix}"*
fi fi
@ -157,7 +162,7 @@ f_rmdns()
ubus call service delete "{\"name\":\"adblock_stats\",\"instances\":\"stats\"}" 2>/dev/null ubus call service delete "{\"name\":\"adblock_stats\",\"instances\":\"stats\"}" 2>/dev/null
} }
# f_dnsrestart: restart the dns server
# f_dnsrestart: restart the dns backend
# #
f_dnsrestart() f_dnsrestart()
{ {
@ -254,7 +259,7 @@ f_query()
printf "%s\n" "::: no active block lists found, please start adblock first" printf "%s\n" "::: no active block lists found, please start adblock first"
elif [ -z "${domain}" ] || [ "${domain}" = "${tld}" ] elif [ -z "${domain}" ] || [ "${domain}" = "${tld}" ]
then then
printf "%s\n" "::: invalid domain input, please submit a specific (sub-)domain, i.e. 'www.abc.xyz'"
printf "%s\n" "::: invalid domain input, please submit a specific (sub-)domain, e.g. 'www.abc.xyz'"
else else
cd "${adb_dnsdir}" cd "${adb_dnsdir}"
while [ "${domain}" != "${tld}" ] while [ "${domain}" != "${tld}" ]
@ -286,6 +291,7 @@ f_log()
logger -t "adblock-[${adb_ver}] ${class}" "${log_msg}" logger -t "adblock-[${adb_ver}] ${class}" "${log_msg}"
if [ "${class}" = "error" ] if [ "${class}" = "error" ]
then then
logger -t "adblock-[${adb_ver}] ${class}" "Please also check the online documentation 'https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md'"
f_rmtemp f_rmtemp
f_rmdns f_rmdns
f_dnsrestart f_dnsrestart
@ -437,7 +443,7 @@ f_main()
fi fi
done done
# restart dns server and write statistics
# restart the dns backend and write statistics to procd service instance
# #
chown "${adb_dns}":"${adb_dns}" "${adb_dnsdir}/${adb_dnsprefix}"* 2>/dev/null chown "${adb_dns}":"${adb_dns}" "${adb_dnsdir}/${adb_dnsprefix}"* 2>/dev/null
f_dnsrestart f_dnsrestart
@ -457,7 +463,7 @@ f_main()
return 0 return 0
fi fi
f_debug f_debug
f_log "error" "status ::: dns server restart with active block lists failed (${sysver})"
f_log "error" "status ::: dns backend restart with active block lists failed (${sysver})"
} }
# handle different adblock actions # handle different adblock actions
@ -486,4 +492,4 @@ then
;; ;;
esac esac
fi fi
exit 0
exit 0

Loading…
Cancel
Save