Browse Source

adblock: update 3.5.5

* accept only ascii aka punycode chars in blocklists to prevent possible
dns backend warnings
* fix cornercase issues in json parsing (backend & frontend)
* slightly optimize tld compression performance
* refine logging
* use uci wrapper where possible
* change indentation from spaces to tabs (saves 8kb)
* add experimental youtube blocklist source

Signed-off-by: Dirk Brenken <dev@brenken.org>
lilik-openwrt-22.03
Dirk Brenken 6 years ago
parent
commit
4987f066f9
6 changed files with 1037 additions and 1041 deletions
  1. +2
    -2
      net/adblock/Makefile
  2. +11
    -9
      net/adblock/files/README.md
  3. +37
    -31
      net/adblock/files/adblock.conf
  4. +55
    -55
      net/adblock/files/adblock.init
  5. +12
    -12
      net/adblock/files/adblock.notify
  6. +920
    -932
      net/adblock/files/adblock.sh

+ 2
- 2
net/adblock/Makefile View File

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


+ 11
- 9
net/adblock/files/README.md View File

@ -61,6 +61,8 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* => infrequent updates, approx. 15.000 entries
* [winspy](https://github.com/crazy-max/WindowsSpyBlocker)
* => infrequent updates, approx. 120 entries
* [youtube]https://api.hackertarget.com/hostsearch/?q=googlevideo.com
* => dynamic request API to filter "random" youtube ad domains (experimental!), approx. 150 entries
* [yoyo](http://pgl.yoyo.org/adservers)
* => weekly updates, approx. 2.500 entries (enabled by default)
* [zeus tracker](https://zeustracker.abuse.ch)
@ -96,7 +98,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* optional: add new adblock sources on your own, see example below
## Prerequisites
* [OpenWrt](https://openwrt.org), tested with the stable release series (17.01.x) and with the latest OpenWrt snapshot
* [OpenWrt](https://openwrt.org), tested with the stable release series (18.06) and with the latest snapshot
* a usual setup with an enabled dns backend at minimum - dump AP modes without a working dns backend are _not_ supported
* a download utility:
* to support all blocklist sources a full version (with ssl support) of 'wget', 'uclient-fetch' with one of the 'libustream-*' ssl libraries, 'aria2c' or 'curl' is required
@ -109,7 +111,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* control the adblock service manually with _/etc/init.d/adblock_ start/stop/restart/reload/suspend/resume/status or use the LuCI frontend
## LuCI adblock companion package
* for easy management of the various blocklist sources and all other adblock options you should use the provided LuCI frontend
* for easy management of the various blocklist sources and adblock runtime options you should use the provided LuCI frontend
* install 'luci-app-adblock' (_opkg install luci-app-adblock_)
* the application is located in LuCI under 'Services' menu
@ -143,7 +145,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* adb\_forcedns => force dns requests to local resolver (bool/default: '0', disabled)
* adb\_forcesrt => force overall sort on low memory devices with less than 64 MB RAM (bool/default: '0', disabled)
* adb\_backup_mode => do not automatically update blocklists during startup, use backups instead (bool/default: '0', disabled)
* adb\maxqueue => size of the download queue to handle downloads & list processing in parallel (int/default: '4')
* adb\_maxqueue => size of the download queue to handle downloads & list processing in parallel (int/default: '4')
* adb\_jail => builds an additional 'Jail' list (/tmp/adb_list.jail) to block access to all domains except those listed in the whitelist file (bool/default: '0', disabled)
* adb\_dnsflush => flush DNS cache after adblock processing, i.e. enable the old restart behavior (bool/default: '0', disabled)
* adb\_notify => send notification emails in case of a processing error or if the overall domain count is &le; 0 (bool/default: '0', disabled)
@ -216,12 +218,12 @@ Finally make this file executable via 'chmod' and test it directly. If no more e
/etc/init.d/adblock status
::: adblock runtime information
+ adblock_status : enabled
+ adblock_version : 3.5.0
+ overall_domains : 102324 (normal mode)
+ fetch_utility : /usr/bin/wget (built-in)
+ dns_backend : kresd (/etc/kresd)
+ last_rundate : 30.01.2018 21:24:11
+ system_release : Turris Omnia, OpenWrt omnia 15.05/3.9.4
+ adblock_version : 3.5.5
+ overall_domains : 97199 (backup mode)
+ fetch_utility : /bin/uclient-fetch (libustream-ssl)
+ dns_backend : unbound (/var/lib/unbound)
+ last_rundate : 01.09.2018 07:09:16
+ system_release : PC Engines APU, OpenWrt SNAPSHOT r7986-dc9388ac55
</code></pre>
**cronjob for a regular block list update (/etc/crontabs/root):**


+ 37
- 31
net/adblock/files/adblock.conf View File

@ -16,127 +16,127 @@ config adblock 'extra'
config source 'adaway'
option adb_src 'https://adaway.org/hosts.txt'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_desc 'focus on mobile ads, infrequent updates, approx. 400 entries'
option enabled '1'
config source 'adguard'
option adb_src 'https://filters.adtidy.org/windows/filters/15.txt'
option adb_src_rset 'BEGIN{FS=\"[/|^|\r]\"}/^\|\|([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([\/\^\r]|$)/{print tolower(\$3)}'
option adb_src_rset 'BEGIN{FS=\"[/|^|\r]\"}/^\|\|([[:alnum:]_-]+\.)+[[:alpha:]]+([\/\^\r]|$)/{print tolower(\$3)}'
option adb_src_desc 'combined adguard dns filter list, frequent updates, approx. 17.000 entries'
option enabled '0'
config source 'bitcoin'
option adb_src 'https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt'
option adb_src_rset '/^0\.0\.0\.0[[:space:]]+([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_rset '/^0\.0\.0\.0[[:space:]]+([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_desc 'focus on malicious bitcoin mining sites, infrequent updates, approx. 80 entries'
option enabled '0'
config source 'blacklist'
option adb_src '/etc/adblock/adblock.blacklist'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'static local domain blacklist, always deny these domains'
option enabled '1'
config source 'disconnect'
option adb_src 'https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'mozilla driven blocklist, numerous updates on the same day, approx. 4.700 entries'
option enabled '1'
config source 'dshield'
option adb_src 'https://www.dshield.org/feeds/suspiciousdomains_Low.txt'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'generic blocklist, daily updates, approx. 3.500 entries'
option enabled '0'
config source 'feodo'
option adb_src 'https://feodotracker.abuse.ch/blocklist/?download=domainblocklist'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'focus on feodo botnet, daily updates, approx. 0-10 entries'
option enabled '0'
config source 'hphosts'
option adb_src 'https://hosts-file.net/ad_servers.txt'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|\$)+/{print tolower(\$2)}'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|\$)+/{print tolower(\$2)}'
option adb_src_desc 'broad blocklist, monthly updates, approx. 19.200 entries'
option enabled '0'
config source 'malware'
option adb_src 'https://mirror.espoch.edu.ec/malwaredomains/justdomains'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'broad blocklist, daily updates, approx. 18.300 entries'
option enabled '0'
config source 'malwarelist'
option adb_src 'http://www.malwaredomainlist.com/hostslist/hosts.txt'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_desc 'focus on malware, daily updates, approx. 1.200 entries'
option enabled '0'
config source 'openphish'
option adb_src 'https://openphish.com/feed.txt'
option adb_src_rset 'BEGIN{FS=\"/\"}/^http[s]?:\/\/([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+(\/|$)/{print tolower(\$3)}'
option adb_src_rset 'BEGIN{FS=\"/\"}/^http[s]?:\/\/([[:alnum:]_-]+\.)+[[:alpha:]]+(\/|$)/{print tolower(\$3)}'
option adb_src_desc 'focus on phishing, numerous updates on the same day, approx. 2.400 entries'
option enabled '0'
config source 'ransomware'
option adb_src 'https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'focus on ransomware by abuse.ch, numerous updates on the same day, approx. 1900 entries'
option enabled '0'
config source 'reg_cn'
option adb_src 'https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([[:alnum:]_-]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_desc 'focus on chinese ads plus generic easylist additions, daily updates, approx. 11.700 entries'
option enabled '0'
config source 'reg_cz'
option adb_src 'https://raw.githubusercontent.com/qxstyles/turris-hole-czech-block-list/master/turris-hole-czech-block-list'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'focus on czech ads maintained by Turris Omnia Users, infrequent updates, approx. 100 entries'
option enabled '0'
config source 'reg_de'
option adb_src 'https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([[:alnum:]_-]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_desc 'focus on german ads plus generic easylist additions, daily updates, approx. 9.200 entries'
option enabled '0'
config source 'reg_id'
option adb_src 'https://easylist-downloads.adblockplus.org/abpindo+easylist.txt'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([[:alnum:]_-]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_desc 'focus on indonesian ads plus generic easylist additions, weekly updates, approx. 9.600 entries'
option enabled '0'
config source 'reg_nl'
option adb_src 'https://easylist-downloads.adblockplus.org/easylistdutch+easylist.txt'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([[:alnum:]_-]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_desc 'focus on dutch ads plus generic easylist additions, weekly updates, approx. 9.400 entries'
option enabled '0'
config source 'reg_pl'
option adb_src 'http://adblocklist.org/adblock-pxf-polish.txt'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([[:alnum:]_-]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_desc 'focus on polish ads, daily updates, approx. 90 entries'
option enabled '0'
config source 'reg_ro'
option adb_src 'https://easylist-downloads.adblockplus.org/rolist+easylist.txt'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([[:alnum:]_-]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_desc 'focus on romanian ads plus generic easylist additions, weekly updates, approx. 9.400 entries'
option enabled '0'
config source 'reg_ru'
option adb_src 'https://easylist-downloads.adblockplus.org/ruadlist+easylist.txt'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_rset 'BEGIN{FS=\"[|^]\"}/^\|\|([[:alnum:]_-]+\.)+[[:alpha:]]+\^("\\\$third-party")?$/{print tolower(\$3)}'
option adb_src_desc 'focus on russian ads plus generic easylist additions, weekly updates, approx. 14.500 entries'
option enabled '0'
config source 'shalla'
option adb_src 'http://www.shallalist.de/Downloads/shallalist.tar.gz'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'huge blocklist archive subdivided in different categories, daily updates. Check http://www.shallalist.de/categories.html for more categories'
list adb_src_cat 'adv'
list adb_src_cat 'costtraps'
@ -147,26 +147,27 @@ config source 'shalla'
config source 'spam404'
option adb_src 'https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)+/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)+/{print tolower(\$1)}'
option adb_src_desc 'generic blocklist, infrequent updates, approx. 6.000 entries'
option enabled '0'
config source 'sysctl'
option adb_src 'http://sysctl.org/cameleon/hosts'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_desc 'broad blocklist, weekly updates, approx. 16.500 entries'
option enabled '0'
config source 'urlhaus'
option adb_src 'https://urlhaus.abuse.ch/downloads/rpz'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)+/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)+/{print tolower(\$1)}'
option adb_src_desc 'urlhaus RPZ domains by abuse.ch, numerous updates on the same day, approx. 3.500 entries'
option enabled '0'
config source 'ut_capitole'
option adb_src 'https://dsi.ut-capitole.fr/blacklists/download/blacklists.tar.gz'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'huge blocklist archive subdivided in different categories, daily updates. Check https://dsi.ut-capitole.fr/blacklists/index_en.php for more categories'
list adb_src_cat 'publicite'
list adb_src_cat 'cryptojacking'
list adb_src_cat 'ddos'
list adb_src_cat 'malware'
@ -176,31 +177,36 @@ config source 'ut_capitole'
config source 'whocares'
option adb_src 'http://someonewhocares.org/hosts/hosts'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_rset '/^127\.0\.0\.1[[:space:]]+([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_desc 'broad blocklist, weekly updates, approx. 10.000 entries'
option enabled '0'
config source 'winspy'
option adb_src 'https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt'
option adb_src_rset '/^0\.0\.0\.0[[:space:]]+([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_rset '/^0\.0\.0\.0[[:space:]]+([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_desc 'focus on windows spy & telemetry domains, infrequent updates, approx. 300 entries'
option enabled '0'
config source 'winhelp'
option adb_src 'http://winhelp2002.mvps.org/hosts.txt'
option adb_src_rset '/^0\.0\.0\.0[[:space:]]+([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_rset '/^0\.0\.0\.0[[:space:]]+([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$2)}'
option adb_src_desc 'broad blocklist, infrequent updates, approx. 13.000 entries'
option enabled '0'
config source 'youtube'
option adb_src 'https://api.hackertarget.com/hostsearch/?q=googlevideo.com'
option adb_src_rset 'BEGIN{FS=\",\"}/^(r[0-9]+\.){1,1}([[:alnum:]_-]+\.)+[[:alpha:]]+/{sub(/\./,\"---\");print tolower(\$1)}'
option adb_src_desc 'focus on youtube ad-related subdomains, dynamic request API, approx. 150 entries'
option enabled '0'
config source 'yoyo'
option adb_src 'https://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'focus on ad related domains, weekly updates, approx. 2.400 entries'
option enabled '1'
config source 'zeus'
option adb_src 'https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist'
option adb_src_rset '/^([^([:space:]|#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_rset '/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}'
option adb_src_desc 'focus on zeus botnet by abuse.ch, daily updates, approx. 400 entries'
option enabled '0'

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

@ -16,97 +16,97 @@ adb_pidfile="/var/run/adblock.pid"
boot()
{
adb_boot=1
rc_procd start_service
adb_boot=1
rc_procd start_service
}
start_service()
{
if [ $("${adb_init}" enabled; printf "%u" ${?}) -eq 0 ]
then
if [ -n "${adb_boot}" ]
then
local trigger="$(uci_get adblock global adb_trigger)"
if [ "${trigger}" != "timed" ]
then
return 0
fi
fi
local nice="$(uci_get adblock extra adb_nice)"
procd_open_instance "adblock"
procd_set_param command "${adb_script}" "${@}"
procd_set_param pidfile "${adb_pidfile}"
procd_set_param nice ${nice:-0}
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
fi
if [ $("${adb_init}" enabled; printf "%u" ${?}) -eq 0 ]
then
if [ -n "${adb_boot}" ]
then
local trigger="$(uci_get adblock global adb_trigger)"
if [ "${trigger}" != "timed" ]
then
return 0
fi
fi
local nice="$(uci_get adblock extra adb_nice)"
procd_open_instance "adblock"
procd_set_param command "${adb_script}" "${@}"
procd_set_param pidfile "${adb_pidfile}"
procd_set_param nice ${nice:-0}
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
fi
}
reload_service()
{
rc_procd start_service reload
rc_procd start_service reload
}
stop_service()
{
rc_procd "${adb_script}" stop
rc_procd start_service
rc_procd "${adb_script}" stop
rc_procd start_service
}
restart()
{
rc_procd start_service restart
rc_procd start_service restart
}
suspend()
{
[ -s "${adb_pidfile}" ] && return 1
rc_procd "${adb_script}" suspend
[ -s "${adb_pidfile}" ] && return 1
rc_procd "${adb_script}" suspend
}
resume()
{
[ -s "${adb_pidfile}" ] && return 1
rc_procd "${adb_script}" resume
[ -s "${adb_pidfile}" ] && return 1
rc_procd "${adb_script}" resume
}
query()
{
[ -s "${adb_pidfile}" ] && return 1
rc_procd "${adb_script}" query "${1}"
[ -s "${adb_pidfile}" ] && return 1
rc_procd "${adb_script}" query "${1}"
}
status()
{
local key keylist value rtfile="$(uci_get adblock extra adb_rtfile)"
local key keylist value rtfile="$(uci_get adblock extra adb_rtfile)"
rtfile="${rtfile:-"/tmp/adb_runtime.json"}"
if [ -s "${rtfile}" ]
then
printf "%s\n" "::: adblock runtime information"
json_load "$(cat "${rtfile}" 2>/dev/null)"
json_select data
json_get_keys keylist
for key in ${keylist}
do
json_get_var value "${key}"
printf " + %-15s : %s\n" "${key}" "${value}"
done
else
printf "%s\n" "::: no adblock runtime information available"
fi
rtfile="${rtfile:-"/tmp/adb_runtime.json"}"
if [ -s "${rtfile}" ]
then
printf "%s\n" "::: adblock runtime information"
json_load_file "${rtfile}"
json_select data
json_get_keys keylist
for key in ${keylist}
do
json_get_var value "${key}"
printf " + %-15s : %s\n" "${key}" "${value}"
done
else
printf "%s\n" "::: no adblock runtime information available"
fi
}
service_triggers()
{
local trigger="$(uci_get adblock global adb_trigger)"
local delay="$(uci_get adblock extra adb_triggerdelay)"
local trigger="$(uci_get adblock global adb_trigger)"
local delay="$(uci_get adblock extra adb_triggerdelay)"
if [ "${trigger}" != "none" ] && [ "${trigger}" != "timed" ]
then
PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
procd_add_interface_trigger "interface.*.up" "${trigger}" "${adb_init}" start
fi
procd_add_reload_trigger "adblock"
if [ "${trigger}" != "none" ] && [ "${trigger}" != "timed" ]
then
PROCD_RELOAD_DELAY=$((${delay:-2} * 1000))
procd_add_interface_trigger "interface.*.up" "${trigger}" "${adb_init}" start
fi
procd_add_reload_trigger "adblock"
}

+ 12
- 12
net/adblock/files/adblock.notify View File

@ -10,7 +10,7 @@
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
mail_ver="1.0.3"
mail_ver="1.0.4"
mail_daemon="$(command -v msmtp)"
mail_profile="adb_notify"
#mail_debug="--debug"
@ -18,22 +18,22 @@ mail_rc=1
# mail header & mail receiver check
#
mail_receiver=""
mail_sender="no-reply@adblock"
mail_receiver="!!!ChangeMe!!!"
mail_topic="${HOSTNAME}: adblock notification"
mail_head="From: ${mail_sender}\nTo: ${mail_receiver}\nSubject: ${mail_topic}\nReply-to: ${mail_sender}\nMime-Version: 1.0\nContent-Type: text/html\nContent-Disposition: inline\n\n"
if [ "${mail_receiver}" = "!!!ChangeMe!!!" ]
if [ -z "${mail_receiver}" ]
then
logger -p "err" -t "adblock-notify-[${mail_ver}]" "please change the 'mail_receiver' in '/etc/adblock/adblock.notify'"
exit ${mail_rc}
logger -p "err" -t "adblock-notify-${mail_ver}[${$}]" "please supply/customize the 'mail_receiver' in '/etc/adblock/adblock.notify'"
exit ${mail_rc}
fi
# mail daemon check
#
if [ ! -x "${mail_daemon}" ]
then
mail_daemon="$(command -v sendmail)"
mail_daemon="$(command -v sendmail)"
fi
# info preparation
@ -42,9 +42,9 @@ sys_info="$(strings /etc/banner 2>/dev/null; ubus call system board | sed -e 's/
adb_info="$(/etc/init.d/adblock status 2>/dev/null)"
if [ -f "/var/log/messages" ]
then
log_info="$(awk '/adblock-/{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"&#8629;"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}' /var/log/messages)"
log_info="$(awk '/adblock-/{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"&#8629;"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}' /var/log/messages)"
else
log_info="$(logread -e "adblock-" | awk '{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"&#8629;"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')"
log_info="$(logread -e "adblock-" | awk '{NR=1;max=79;if(length($0)>max+1)while($0){if(NR==1){print substr($0,1,max),"&#8629;"} else {print " ",substr($0,1,max)}{$0=substr($0,max+1);NR=NR+1}}else print}')"
fi
# mail body
@ -59,11 +59,11 @@ mail_text="${mail_text}</pre></body></html>"
#
if [ -x "${mail_daemon}" ]
then
printf "%b" "${mail_head}${mail_text}" 2>/dev/null | "${mail_daemon}" ${mail_debug} -a "${mail_profile}" "${mail_receiver}" >/dev/null 2>&1
mail_rc=${?}
logger -p "info" -t "adblock-notify-[${mail_ver}]" "mail sent to '${mail_receiver}' with rc '${mail_rc}'"
printf "%b" "${mail_head}${mail_text}" 2>/dev/null | "${mail_daemon}" ${mail_debug} -a "${mail_profile}" "${mail_receiver}" >/dev/null 2>&1
mail_rc=${?}
logger -p "info" -t "adblock-notify-${mail_ver}[${$}]" "mail sent to '${mail_receiver}' with rc '${mail_rc}'"
else
logger -p "err" -t "adblock-notify-[${mail_ver}]" "msmtp mail daemon not found"
logger -p "err" -t "adblock-notify-${mail_ver}[${$}]" "msmtp mail daemon not found"
fi
exit ${mail_rc}

+ 920
- 932
net/adblock/files/adblock.sh
File diff suppressed because it is too large
View File


Loading…
Cancel
Save