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>
This commit is contained in:
Dirk Brenken 2018-09-01 08:35:35 +02:00
parent 67ff849bce
commit 4987f066f9
6 changed files with 993 additions and 997 deletions

View file

@ -6,8 +6,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=adblock PKG_NAME:=adblock
PKG_VERSION:=3.5.4 PKG_VERSION:=3.5.5
PKG_RELEASE:=2 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>

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 * => infrequent updates, approx. 15.000 entries
* [winspy](https://github.com/crazy-max/WindowsSpyBlocker) * [winspy](https://github.com/crazy-max/WindowsSpyBlocker)
* => infrequent updates, approx. 120 entries * => 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) * [yoyo](http://pgl.yoyo.org/adservers)
* => weekly updates, approx. 2.500 entries (enabled by default) * => weekly updates, approx. 2.500 entries (enabled by default)
* [zeus tracker](https://zeustracker.abuse.ch) * [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 * optional: add new adblock sources on your own, see example below
## Prerequisites ## 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 usual setup with an enabled dns backend at minimum - dump AP modes without a working dns backend are _not_ supported
* a download utility: * 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 * 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 * 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 ## 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_) * install 'luci-app-adblock' (_opkg install luci-app-adblock_)
* the application is located in LuCI under 'Services' menu * 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\_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\_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\_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\_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\_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) * 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 /etc/init.d/adblock status
::: adblock runtime information ::: adblock runtime information
+ adblock_status : enabled + adblock_status : enabled
+ adblock_version : 3.5.0 + adblock_version : 3.5.5
+ overall_domains : 102324 (normal mode) + overall_domains : 97199 (backup mode)
+ fetch_utility : /usr/bin/wget (built-in) + fetch_utility : /bin/uclient-fetch (libustream-ssl)
+ dns_backend : kresd (/etc/kresd) + dns_backend : unbound (/var/lib/unbound)
+ last_rundate : 30.01.2018 21:24:11 + last_rundate : 01.09.2018 07:09:16
+ system_release : Turris Omnia, OpenWrt omnia 15.05/3.9.4 + system_release : PC Engines APU, OpenWrt SNAPSHOT r7986-dc9388ac55
</code></pre> </code></pre>
**cronjob for a regular block list update (/etc/crontabs/root):** **cronjob for a regular block list update (/etc/crontabs/root):**

View file

@ -16,127 +16,127 @@ config adblock 'extra'
config source 'adaway' config source 'adaway'
option adb_src 'https://adaway.org/hosts.txt' 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 adb_src_desc 'focus on mobile ads, infrequent updates, approx. 400 entries'
option enabled '1' option enabled '1'
config source 'adguard' config source 'adguard'
option adb_src 'https://filters.adtidy.org/windows/filters/15.txt' 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 adb_src_desc 'combined adguard dns filter list, frequent updates, approx. 17.000 entries'
option enabled '0' option enabled '0'
config source 'bitcoin' config source 'bitcoin'
option adb_src 'https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt' 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 adb_src_desc 'focus on malicious bitcoin mining sites, infrequent updates, approx. 80 entries'
option enabled '0' option enabled '0'
config source 'blacklist' config source 'blacklist'
option adb_src '/etc/adblock/adblock.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 adb_src_desc 'static local domain blacklist, always deny these domains'
option enabled '1' option enabled '1'
config source 'disconnect' config source 'disconnect'
option adb_src 'https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt' 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 adb_src_desc 'mozilla driven blocklist, numerous updates on the same day, approx. 4.700 entries'
option enabled '1' option enabled '1'
config source 'dshield' config source 'dshield'
option adb_src 'https://www.dshield.org/feeds/suspiciousdomains_Low.txt' 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 adb_src_desc 'generic blocklist, daily updates, approx. 3.500 entries'
option enabled '0' option enabled '0'
config source 'feodo' config source 'feodo'
option adb_src 'https://feodotracker.abuse.ch/blocklist/?download=domainblocklist' 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 adb_src_desc 'focus on feodo botnet, daily updates, approx. 0-10 entries'
option enabled '0' option enabled '0'
config source 'hphosts' config source 'hphosts'
option adb_src 'https://hosts-file.net/ad_servers.txt' 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 adb_src_desc 'broad blocklist, monthly updates, approx. 19.200 entries'
option enabled '0' option enabled '0'
config source 'malware' config source 'malware'
option adb_src 'https://mirror.espoch.edu.ec/malwaredomains/justdomains' 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 adb_src_desc 'broad blocklist, daily updates, approx. 18.300 entries'
option enabled '0' option enabled '0'
config source 'malwarelist' config source 'malwarelist'
option adb_src 'http://www.malwaredomainlist.com/hostslist/hosts.txt' 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 adb_src_desc 'focus on malware, daily updates, approx. 1.200 entries'
option enabled '0' option enabled '0'
config source 'openphish' config source 'openphish'
option adb_src 'https://openphish.com/feed.txt' 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 adb_src_desc 'focus on phishing, numerous updates on the same day, approx. 2.400 entries'
option enabled '0' option enabled '0'
config source 'ransomware' config source 'ransomware'
option adb_src 'https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt' 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 adb_src_desc 'focus on ransomware by abuse.ch, numerous updates on the same day, approx. 1900 entries'
option enabled '0' option enabled '0'
config source 'reg_cn' config source 'reg_cn'
option adb_src 'https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt' 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 adb_src_desc 'focus on chinese ads plus generic easylist additions, daily updates, approx. 11.700 entries'
option enabled '0' option enabled '0'
config source 'reg_cz' 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 '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 adb_src_desc 'focus on czech ads maintained by Turris Omnia Users, infrequent updates, approx. 100 entries'
option enabled '0' option enabled '0'
config source 'reg_de' config source 'reg_de'
option adb_src 'https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt' 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 adb_src_desc 'focus on german ads plus generic easylist additions, daily updates, approx. 9.200 entries'
option enabled '0' option enabled '0'
config source 'reg_id' config source 'reg_id'
option adb_src 'https://easylist-downloads.adblockplus.org/abpindo+easylist.txt' 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 adb_src_desc 'focus on indonesian ads plus generic easylist additions, weekly updates, approx. 9.600 entries'
option enabled '0' option enabled '0'
config source 'reg_nl' config source 'reg_nl'
option adb_src 'https://easylist-downloads.adblockplus.org/easylistdutch+easylist.txt' 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 adb_src_desc 'focus on dutch ads plus generic easylist additions, weekly updates, approx. 9.400 entries'
option enabled '0' option enabled '0'
config source 'reg_pl' config source 'reg_pl'
option adb_src 'http://adblocklist.org/adblock-pxf-polish.txt' 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 adb_src_desc 'focus on polish ads, daily updates, approx. 90 entries'
option enabled '0' option enabled '0'
config source 'reg_ro' config source 'reg_ro'
option adb_src 'https://easylist-downloads.adblockplus.org/rolist+easylist.txt' 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 adb_src_desc 'focus on romanian ads plus generic easylist additions, weekly updates, approx. 9.400 entries'
option enabled '0' option enabled '0'
config source 'reg_ru' config source 'reg_ru'
option adb_src 'https://easylist-downloads.adblockplus.org/ruadlist+easylist.txt' 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 adb_src_desc 'focus on russian ads plus generic easylist additions, weekly updates, approx. 14.500 entries'
option enabled '0' option enabled '0'
config source 'shalla' config source 'shalla'
option adb_src 'http://www.shallalist.de/Downloads/shallalist.tar.gz' 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' 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 'adv'
list adb_src_cat 'costtraps' list adb_src_cat 'costtraps'
@ -147,26 +147,27 @@ config source 'shalla'
config source 'spam404' config source 'spam404'
option adb_src 'https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt' 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 adb_src_desc 'generic blocklist, infrequent updates, approx. 6.000 entries'
option enabled '0' option enabled '0'
config source 'sysctl' config source 'sysctl'
option adb_src 'http://sysctl.org/cameleon/hosts' 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 adb_src_desc 'broad blocklist, weekly updates, approx. 16.500 entries'
option enabled '0' option enabled '0'
config source 'urlhaus' config source 'urlhaus'
option adb_src 'https://urlhaus.abuse.ch/downloads/rpz' 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 adb_src_desc 'urlhaus RPZ domains by abuse.ch, numerous updates on the same day, approx. 3.500 entries'
option enabled '0' option enabled '0'
config source 'ut_capitole' config source 'ut_capitole'
option adb_src 'https://dsi.ut-capitole.fr/blacklists/download/blacklists.tar.gz' 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' 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 'cryptojacking'
list adb_src_cat 'ddos' list adb_src_cat 'ddos'
list adb_src_cat 'malware' list adb_src_cat 'malware'
@ -176,31 +177,36 @@ config source 'ut_capitole'
config source 'whocares' config source 'whocares'
option adb_src 'http://someonewhocares.org/hosts/hosts' 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 adb_src_desc 'broad blocklist, weekly updates, approx. 10.000 entries'
option enabled '0' option enabled '0'
config source 'winspy' config source 'winspy'
option adb_src 'https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt' 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 adb_src_desc 'focus on windows spy & telemetry domains, infrequent updates, approx. 300 entries'
option enabled '0' option enabled '0'
config source 'winhelp' config source 'winhelp'
option adb_src 'http://winhelp2002.mvps.org/hosts.txt' 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 adb_src_desc 'broad blocklist, infrequent updates, approx. 13.000 entries'
option enabled '0' 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' config source 'yoyo'
option adb_src 'https://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext' 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 adb_src_desc 'focus on ad related domains, weekly updates, approx. 2.400 entries'
option enabled '1' option enabled '1'
config source 'zeus' config source 'zeus'
option adb_src 'https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist' 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 adb_src_desc 'focus on zeus botnet by abuse.ch, daily updates, approx. 400 entries'
option enabled '0' option enabled '0'

View file

@ -85,7 +85,7 @@ status()
if [ -s "${rtfile}" ] if [ -s "${rtfile}" ]
then then
printf "%s\n" "::: adblock runtime information" printf "%s\n" "::: adblock runtime information"
json_load "$(cat "${rtfile}" 2>/dev/null)" json_load_file "${rtfile}"
json_select data json_select data
json_get_keys keylist json_get_keys keylist
for key in ${keylist} for key in ${keylist}

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"
mail_ver="1.0.3" mail_ver="1.0.4"
mail_daemon="$(command -v msmtp)" mail_daemon="$(command -v msmtp)"
mail_profile="adb_notify" mail_profile="adb_notify"
#mail_debug="--debug" #mail_debug="--debug"
@ -18,14 +18,14 @@ mail_rc=1
# mail header & mail receiver check # mail header & mail receiver check
# #
mail_receiver=""
mail_sender="no-reply@adblock" mail_sender="no-reply@adblock"
mail_receiver="!!!ChangeMe!!!"
mail_topic="${HOSTNAME}: adblock notification" 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" 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 then
logger -p "err" -t "adblock-notify-[${mail_ver}]" "please change the 'mail_receiver' in '/etc/adblock/adblock.notify'" logger -p "err" -t "adblock-notify-${mail_ver}[${$}]" "please supply/customize the 'mail_receiver' in '/etc/adblock/adblock.notify'"
exit ${mail_rc} exit ${mail_rc}
fi fi
@ -61,9 +61,9 @@ if [ -x "${mail_daemon}" ]
then then
printf "%b" "${mail_head}${mail_text}" 2>/dev/null | "${mail_daemon}" ${mail_debug} -a "${mail_profile}" "${mail_receiver}" >/dev/null 2>&1 printf "%b" "${mail_head}${mail_text}" 2>/dev/null | "${mail_daemon}" ${mail_debug} -a "${mail_profile}" "${mail_receiver}" >/dev/null 2>&1
mail_rc=${?} mail_rc=${?}
logger -p "info" -t "adblock-notify-[${mail_ver}]" "mail sent to '${mail_receiver}' with rc '${mail_rc}'" logger -p "info" -t "adblock-notify-${mail_ver}[${$}]" "mail sent to '${mail_receiver}' with rc '${mail_rc}'"
else 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 fi
exit ${mail_rc} exit ${mail_rc}

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="3.5.4-2" adb_ver="3.5.5"
adb_sysver="unknown" adb_sysver="unknown"
adb_enabled=0 adb_enabled=0
adb_debug=0 adb_debug=0
@ -68,16 +68,6 @@ f_envload()
adb_hashutil="$(command -v md5sum)" adb_hashutil="$(command -v md5sum)"
fi fi
# source in system libraries
#
if [ -r "/lib/functions.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ]
then
. "/lib/functions.sh"
. "/usr/share/libubox/jshn.sh"
else
f_log "err" "system libraries not found"
fi
# parse 'global' and 'extra' section by callback # parse 'global' and 'extra' section by callback
# #
config_cb() config_cb()
@ -174,7 +164,7 @@ f_envload()
f_extconf f_extconf
f_temp f_temp
f_rmdns f_rmdns
f_jsnup f_jsnup "disabled"
f_log "info" "adblock is currently disabled, please set adb_enabled to '1' to use this service" f_log "info" "adblock is currently disabled, please set adb_enabled to '1' to use this service"
exit 0 exit 0
fi fi
@ -215,6 +205,11 @@ f_envcheck()
{ {
local ssl_lib local ssl_lib
# startup message
#
f_log "info" "adblock instance started ::: action: ${adb_action}, priority: ${adb_nice:-"0"}, pid: ${$}"
f_jsnup "running"
# check external uci config files # check external uci config files
# #
f_extconf f_extconf
@ -257,10 +252,7 @@ f_envcheck()
f_log "err" "download utility not found, please install 'uclient-fetch' with 'libustream-mbedtls' or the full 'wget' package" f_log "err" "download utility not found, please install 'uclient-fetch' with 'libustream-mbedtls' or the full 'wget' package"
fi fi
adb_fetchinfo="${adb_fetchutil} (${ssl_lib:-"-"})" adb_fetchinfo="${adb_fetchutil} (${ssl_lib:-"-"})"
f_temp f_temp
f_jsnup "running"
f_log "info" "start adblock processing (${adb_action})"
} }
# create temporary files and directories # create temporary files and directories
@ -322,7 +314,7 @@ f_uci()
change="$(uci -q changes "${config}" | awk '{ORS=" "; print $0}')" change="$(uci -q changes "${config}" | awk '{ORS=" "; print $0}')"
if [ -n "${change}" ] if [ -n "${change}" ]
then then
uci -q commit "${config}" uci_commit "${config}"
case "${config}" in case "${config}" in
firewall) firewall)
/etc/init.d/firewall reload >/dev/null 2>&1 /etc/init.d/firewall reload >/dev/null 2>&1
@ -365,29 +357,29 @@ f_extconf()
case "${adb_dns}" in case "${adb_dns}" in
dnsmasq) dnsmasq)
uci_config="dhcp" uci_config="dhcp"
if [ ${adb_enabled} -eq 1 ] && [ -z "$(uci -q get dhcp.@dnsmasq[${adb_dnsinstance}].serversfile | grep -Fo "${adb_dnsdir}/${adb_dnsfile}")" ] if [ ${adb_enabled} -eq 1 ] && [ -z "$(uci_get dhcp "@dnsmasq[${adb_dnsinstance}].serversfile" | grep -Fo "${adb_dnsdir}/${adb_dnsfile}")" ]
then then
uci -q set dhcp.@dnsmasq[${adb_dnsinstance}].serversfile="${adb_dnsdir}/${adb_dnsfile}" uci_set dhcp "@dnsmasq[${adb_dnsinstance}].serversfile" "${adb_dnsdir}/${adb_dnsfile}"
elif [ ${adb_enabled} -eq 0 ] && [ -n "$(uci -q get dhcp.@dnsmasq[${adb_dnsinstance}].serversfile | grep -Fo "${adb_dnsdir}/${adb_dnsfile}")" ] elif [ ${adb_enabled} -eq 0 ] && [ -n "$(uci_get dhcp "@dnsmasq[${adb_dnsinstance}].serversfile" | grep -Fo "${adb_dnsdir}/${adb_dnsfile}")" ]
then then
uci -q delete dhcp.@dnsmasq[${adb_dnsinstance}].serversfile uci_remove dhcp "@dnsmasq[${adb_dnsinstance}].serversfile"
fi fi
;; ;;
kresd) kresd)
uci_config="resolver" uci_config="resolver"
if [ ${adb_enabled} -eq 1 ] && [ -z "$(uci -q get resolver.kresd.rpz_file | grep -Fo "${adb_dnsdir}/${adb_dnsfile}")" ] if [ ${adb_enabled} -eq 1 ] && [ -z "$(uci_get resolver kresd.rpz_file | grep -Fo "${adb_dnsdir}/${adb_dnsfile}")" ]
then then
uci -q add_list resolver.kresd.rpz_file="${adb_dnsdir}/${adb_dnsfile}" uci -q add_list resolver.kresd.rpz_file="${adb_dnsdir}/${adb_dnsfile}"
elif [ ${adb_enabled} -eq 0 ] && [ -n "$(uci -q get resolver.kresd.rpz_file | grep -Fo "${adb_dnsdir}/${adb_dnsfile}")" ] elif [ ${adb_enabled} -eq 0 ] && [ -n "$(uci_get resolver kresd.rpz_file | grep -Fo "${adb_dnsdir}/${adb_dnsfile}")" ]
then then
uci -q del_list resolver.kresd.rpz_file="${adb_dnsdir}/${adb_dnsfile}" uci -q del_list resolver.kresd.rpz_file="${adb_dnsdir}/${adb_dnsfile}"
fi fi
if [ ${adb_enabled} -eq 1 ] && [ ${adb_dnsflush} -eq 0 ] && [ "$(uci -q get resolver.kresd.keep_cache)" != "1" ] if [ ${adb_enabled} -eq 1 ] && [ ${adb_dnsflush} -eq 0 ] && [ "$(uci_get resolver "kresd.keep_cache")" != "1" ]
then then
uci -q set resolver.kresd.keep_cache="1" uci_set resolver "kresd.keep_cache" "1"
elif [ ${adb_enabled} -eq 0 ] || ([ ${adb_dnsflush} -eq 1 ] && [ "$(uci -q get resolver.kresd.keep_cache)" = "1" ]) elif [ ${adb_enabled} -eq 0 ] || ([ ${adb_dnsflush} -eq 1 ] && [ "$(uci_get resolver "kresd.keep_cache")" = "1" ])
then then
uci -q set resolver.kresd.keep_cache="0" uci_set resolver "kresd.keep_cache" "0"
fi fi
;; ;;
esac esac
@ -395,7 +387,7 @@ f_extconf()
uci_config="firewall" uci_config="firewall"
if [ ${adb_enabled} -eq 1 ] && [ ${adb_forcedns} -eq 1 ] && \ if [ ${adb_enabled} -eq 1 ] && [ ${adb_forcedns} -eq 1 ] && \
[ -z "$(uci -q get firewall.adblock_dns_53)" ] && [ $(/etc/init.d/firewall enabled; printf '%u' ${?}) -eq 0 ] [ -z "$(uci_get firewall adblock_dns_53)" ] && [ $(/etc/init.d/firewall enabled; printf '%u' ${?}) -eq 0 ]
then then
for port in ${port_list} for port in ${port_list}
do do
@ -407,7 +399,7 @@ f_extconf()
uci_set firewall "adblock_dns_${port}" "dest_port" "${port}" uci_set firewall "adblock_dns_${port}" "dest_port" "${port}"
uci_set firewall "adblock_dns_${port}" "target" "DNAT" uci_set firewall "adblock_dns_${port}" "target" "DNAT"
done done
elif [ -n "$(uci -q get firewall.adblock_dns_53)" ] && ([ ${adb_enabled} -eq 0 ] || [ ${adb_forcedns} -eq 0 ]) elif [ -n "$(uci_get firewall adblock_dns_53)" ] && ([ ${adb_enabled} -eq 0 ] || [ ${adb_forcedns} -eq 0 ])
then then
for port in ${port_list} for port in ${port_list}
do do
@ -555,7 +547,7 @@ f_list()
if [ ${?} -eq 0 ] && [ -n "${adb_dnsheader}" ] if [ ${?} -eq 0 ] && [ -n "${adb_dnsheader}" ]
then then
printf '%s\n' "${adb_dnsheader}" | cat - "${adb_dnsdir}/${adb_dnsfile}" > "${adb_tmpdir}/${adb_dnsfile}" printf '%s\n' "${adb_dnsheader}" | cat - "${adb_dnsdir}/${adb_dnsfile}" > "${adb_tmpdir}/${adb_dnsfile}"
cat "${adb_tmpdir}/${adb_dnsfile}" > "${adb_dnsdir}/${adb_dnsfile}" mv -f "${adb_tmpdir}/${adb_dnsfile}" "${adb_dnsdir}/${adb_dnsfile}"
fi fi
adb_rc=${?} adb_rc=${?}
;; ;;
@ -571,39 +563,28 @@ f_tld()
local cnt cnt_srt cnt_tld source="${1}" temp="${1}.tld" local cnt cnt_srt cnt_tld source="${1}" temp="${1}.tld"
cnt="$(wc -l 2>/dev/null < "${source}")" cnt="$(wc -l 2>/dev/null < "${source}")"
sort -u "${source}" > "${temp}" awk 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' "${source}" > "${temp}"
if [ ${?} -eq 0 ] if [ ${?} -eq 0 ]
then then
cnt_srt="$(wc -l 2>/dev/null < "${temp}")" sort -u "${temp}" > "${source}"
awk -F "." '{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' "${temp}" > "${source}"
if [ ${?} -eq 0 ] if [ ${?} -eq 0 ]
then then
sort "${source}" > "${temp}" cnt_srt="$(wc -l 2>/dev/null < "${source}")"
awk '{if(NR==1){tld=$NF};while(getline){if($NF!~tld"\\."){print tld;tld=$NF}}print tld}' "${source}" > "${temp}"
if [ ${?} -eq 0 ] if [ ${?} -eq 0 ]
then then
awk '{if(NR==1){tld=$NF};while(getline){if($NF!~tld"\\."){print tld;tld=$NF}}print tld}' "${temp}" > "${source}" awk 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' "${temp}" > "${source}"
if [ ${?} -eq 0 ]
then
awk -F "." '{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' "${source}" > "${temp}"
if [ ${?} -eq 0 ]
then
sort "${temp}" > "${source}"
if [ ${?} -eq 0 ] if [ ${?} -eq 0 ]
then then
cnt_tld="$(wc -l 2>/dev/null < "${source}")" cnt_tld="$(wc -l 2>/dev/null < "${source}")"
else else
cat "${temp}" > "${source}" mv -f "${temp}" > "${source}"
fi fi
fi fi
else else
cat "${temp}" > "${source}" mv -f "${temp}" "${source}"
fi fi
fi fi
else
cat "${temp}" > "${source}"
fi
fi
rm -f "${temp}"
f_log "debug" "f_tld ::: source: ${source}, cnt: ${cnt:-"-"}, cnt_srt: ${cnt_srt:-"-"}, cnt_tld: ${cnt_tld:-"-"}" f_log "debug" "f_tld ::: source: ${source}, cnt: ${cnt:-"-"}, cnt_srt: ${cnt_srt:-"-"}, cnt_tld: ${cnt_tld:-"-"}"
} }
@ -720,20 +701,16 @@ f_query()
# #
f_jsnup() f_jsnup()
{ {
local bg_pid rundate status="${1:-"enabled"}" mode="normal mode" no_mail=0 local run_time bg_pid status="${1:-"enabled"}" mode="normal mode" no_mail=0
if [ ${adb_rc} -gt 0 ] if [ ${adb_rc} -gt 0 ]
then then
status="error" status="error"
rundate="$(/bin/date "+%d.%m.%Y %H:%M:%S")" run_time="$(/bin/date "+%d.%m.%Y %H:%M:%S")"
fi
if [ ${adb_enabled} -eq 0 ]
then
status="disabled"
fi fi
if [ "${status}" = "enabled" ] if [ "${status}" = "enabled" ]
then then
rundate="$(/bin/date "+%d.%m.%Y %H:%M:%S")" run_time="$(/bin/date "+%d.%m.%Y %H:%M:%S")"
fi fi
if [ "${status}" = "suspend" ] if [ "${status}" = "suspend" ]
then then
@ -749,36 +726,26 @@ f_jsnup()
mode="backup mode" mode="backup mode"
fi fi
if [ -s "${adb_rtfile}" ] if [ -z "${adb_fetchinfo}" ]
then
json_load "$(cat "${adb_rtfile}" 2>/dev/null)"
json_select data
if [ -z "${adb_fetchinfo}" ] && [ -s "${adb_rtfile}" ]
then then
json_get_var adb_fetchinfo "fetch_utility" json_get_var adb_fetchinfo "fetch_utility"
fi fi
if [ -z "${rundate}" ]
then
json_get_var rundate "last_rundate"
fi
if [ -z "${adb_cnt}" ] if [ -z "${adb_cnt}" ]
then then
json_get_var adb_cnt "overall_domains" json_get_var adb_cnt "overall_domains"
adb_cnt="${adb_cnt%% *}" adb_cnt="${adb_cnt%% *}"
fi fi
if [ -z "${run_time}" ]
then
json_get_var run_time "last_rundate"
fi fi
json_init
json_add_object "data"
json_add_string "adblock_status" "${status}" json_add_string "adblock_status" "${status}"
json_add_string "adblock_version" "${adb_ver}" json_add_string "adblock_version" "${adb_ver}"
json_add_string "overall_domains" "${adb_cnt:-0} (${mode})" json_add_string "overall_domains" "${adb_cnt:-0} (${mode})"
json_add_string "fetch_utility" "${adb_fetchinfo:-"-"}" json_add_string "fetch_utility" "${adb_fetchinfo:-"-"}"
json_add_string "dns_backend" "${adb_dns} (${adb_dnsdir})" json_add_string "dns_backend" "${adb_dns} (${adb_dnsdir})"
json_add_string "last_rundate" "${rundate:-"-"}" json_add_string "last_rundate" "${run_time:-"-"}"
json_add_string "system_release" "${adb_sysver}" json_add_string "system_release" "${adb_sysver}"
json_close_object
json_dump > "${adb_rtfile}" json_dump > "${adb_rtfile}"
if [ ${adb_notify} -eq 1 ] && [ ${no_mail} -eq 0 ] && [ -x /etc/adblock/adblock.notify ] && \ if [ ${adb_notify} -eq 1 ] && [ ${no_mail} -eq 0 ] && [ -x /etc/adblock/adblock.notify ] && \
@ -798,12 +765,12 @@ f_log()
if [ -n "${log_msg}" ] && ([ "${class}" != "debug" ] || [ ${adb_debug} -eq 1 ]) if [ -n "${log_msg}" ] && ([ "${class}" != "debug" ] || [ ${adb_debug} -eq 1 ])
then then
logger -p "${class}" -t "adblock-[${adb_ver}]" "${log_msg}" logger -p "${class}" -t "adblock-${adb_ver}[${$}]" "${log_msg}"
if [ "${class}" = "err" ] if [ "${class}" = "err" ]
then then
f_rmdns f_rmdns
f_jsnup f_jsnup
logger -p "${class}" -t "adblock-[${adb_ver}]" "Please also check 'https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md'" logger -p "${class}" -t "adblock-${adb_ver}[${$}]" "Please also check 'https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md'"
exit 1 exit 1
fi fi
fi fi
@ -829,11 +796,11 @@ f_main()
# #
if [ -s "${adb_whitelist}" ] if [ -s "${adb_whitelist}" ]
then then
adb_whitelist_rset="/^([^([:space:]|\#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}" adb_whitelist_rset="/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}"
awk "${adb_whitelist_rset}" "${adb_whitelist}" > "${adb_tmpdir}/tmp.raw_whitelist" awk "${adb_whitelist_rset}" "${adb_whitelist}" > "${adb_tmpdir}/tmp.raw_whitelist"
f_tld "${adb_tmpdir}/tmp.raw_whitelist" f_tld "${adb_tmpdir}/tmp.raw_whitelist"
adb_whitelist_rset="/^([^([:space:]|\#|\*|\/).]+\.)+[[:alpha:]]+([[:space:]]|$)/{gsub(\"\\\.\",\"\\\.\",\$1);print tolower(\"^\"\$1\"\\\|\\\.\"\$1)}" adb_whitelist_rset="/^([[:alnum:]_-]+\.)+[[:alpha:]]+([[:space:]]|$)/{gsub(\"\\\.\",\"\\\.\",\$1);print tolower(\"^\"\$1\"\\\|\\\.\"\$1)}"
awk "${adb_whitelist_rset}" "${adb_tmpdir}/tmp.raw_whitelist" > "${adb_tmpdir}/tmp.rem_whitelist" awk "${adb_whitelist_rset}" "${adb_tmpdir}/tmp.raw_whitelist" > "${adb_tmpdir}/tmp.rem_whitelist"
if [ -n "${adb_dnsallow}" ] if [ -n "${adb_dnsallow}" ]
@ -1052,6 +1019,27 @@ f_main()
exit ${adb_rc} exit ${adb_rc}
} }
# source required system libraries
#
if [ -r "/lib/functions.sh" ] && [ -r "/usr/share/libubox/jshn.sh" ]
then
. "/lib/functions.sh"
. "/usr/share/libubox/jshn.sh"
else
f_log "err" "system libraries not found"
fi
# initialize json runtime file
#
json_load_file "${adb_rtfile}" >/dev/null 2>&1
json_select data >/dev/null 2>&1
if [ ${?} -ne 0 ]
then
> "${adb_rtfile}"
json_init
json_add_object "data"
fi
# handle different adblock actions # handle different adblock actions
# #
f_envload f_envload