adblock: update 2.8.0

* add bind support (see readme)
* export all blocked domains in one central file (adb_list.overall)
  * prerequisite for proper bind support
  * much faster sort operation with less memory consumption
  * backups are still handled per source separately,
    to be more flexible in adding/removing block list sources
* add additional 'wan6' interface trigger in default configuration
* various small fixes & optimizations

Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
Dirk Brenken 2017-06-26 20:58:29 +02:00
parent 88be3d2d49
commit e660813798
4 changed files with 100 additions and 87 deletions

View file

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=adblock PKG_NAME:=adblock
PKG_VERSION:=2.7.1 PKG_VERSION:=2.8.0
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>
@ -21,7 +21,7 @@ define Package/adblock
endef endef
define Package/adblock/description define Package/adblock/description
Powerful adblock script to block ad/abuse domains via dnsmasq or unbound dns backend. Powerful adblock script to block ad/abuse domains via dnsmasq, unbound or bind dns backend.
The script supports many domain blacklist sites plus manual black- and whitelist overrides. The script supports many domain blacklist sites plus manual black- and whitelist overrides.
Please see https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md for further information. Please see https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md for further information.

View file

@ -55,15 +55,15 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* => daily updates, approx. 440 entries * => daily updates, approx. 440 entries
* zero-conf like automatic installation & setup, usually no manual changes needed * zero-conf like automatic installation & setup, usually no manual changes needed
* simple but yet powerful adblock engine: adblock does not use error prone external iptables rulesets, http pixel server instances and things like that * simple but yet powerful adblock engine: adblock does not use error prone external iptables rulesets, http pixel server instances and things like that
* automatically selects dnsmasq or unbound as dns backend * automatically selects dnsmasq, unbound or bind as dns backend
* automatically selects uclient-fetch or wget as download utility (other tools like curl or aria2c are supported as well) * automatically selects uclient-fetch or wget as download utility (other tools like curl or aria2c are supported as well)
* support http only mode (without installed ssl library) for all non-SSL blocklist sources * support http only mode (without installed ssl library) for all non-SSL blocklist sources
* automatically supports a wide range of router modes, even AP modes are supported * automatically supports a wide range of router modes, even AP modes are supported
* full IPv4 and IPv6 support * full IPv4 and IPv6 support
* supports tld compression (top level domain compression), this feature removes thousands of needless host entries from the block lists and lowers the memory footprint for the dns backends * supports tld compression (top level domain compression), this feature removes thousands of needless host entries from the block list and lowers the memory footprint for the dns backends
* each block list source will be updated and processed separately * each block list source will be updated and processed separately
* block list source parsing by fast & flexible regex rulesets * block list source parsing by fast & flexible regex rulesets
* overall duplicate removal in separate block lists * overall duplicate removal in central block list (adb_list.overall)
* additional whitelist for manual overrides, located by default in /etc/adblock/adblock.whitelist * additional whitelist for manual overrides, located by default in /etc/adblock/adblock.whitelist
* quality checks during block list update to ensure a reliable dns backend service * quality checks during block list update to ensure a reliable dns backend service
* minimal status & error logging to syslog, enable debug logging to receive more output * minimal status & error logging to syslog, enable debug logging to receive more output
@ -105,7 +105,7 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* **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 procd interface trigger:** restrict the procd interface trigger to a (list of) certain interface(s) (default: wan). To disable it at all, remove all entries * **restrict procd interface trigger:** restrict the procd interface trigger to a (list of) certain interface(s) (default: wan). To disable it at all, remove all entries
* **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]_
* **domain query:** to query the active block lists for a specific domain, please run _/etc/init.d/adblock query `<DOMAIN>`_ (see example below) * **domain query:** to query the active block list for a specific domain, please run _/etc/init.d/adblock query `<DOMAIN>`_ (see example below)
* **add new list sources:** you could add new block list sources on your own via uci config, all you need is a source url and an awk one-liner (see example below) * **add new list sources:** you could add new block list sources on your own via uci config, all you need is a source url and an awk one-liner (see example below)
* **disable active dns probing in windows 10:** to prevent a yellow exclamation mark on your internet connection icon (which wrongly means connected, but no internet), please change the following registry key/value from "1" to "0" _HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\EnableActiveProbing_ * **disable active dns probing in windows 10:** to prevent a yellow exclamation mark on your internet connection icon (which wrongly means connected, but no internet), please change the following registry key/value from "1" to "0" _HKLM\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\EnableActiveProbing_
@ -119,16 +119,40 @@ A lot of people already use adblocker plugins within their desktop browsers, but
* adb\_triggerdelay => additional trigger delay in seconds before adblock processing starts (default: '2') * adb\_triggerdelay => additional trigger delay in seconds before adblock processing starts (default: '2')
* adb\_forcedns => force dns requests to local resolver (default: '0', disabled) * adb\_forcedns => force dns requests to local resolver (default: '0', disabled)
* adb\_forcesrt => force overall sort on low memory devices with less than 64 MB RAM (default: '0', disabled) * adb\_forcesrt => force overall sort on low memory devices with less than 64 MB RAM (default: '0', disabled)
* adb\_manmode => do not automatically update blocklists during startup, use blocklist backups instead (default: '0', disabled) * adb\_manmode => do not automatically update block lists during startup, use backups instead (default: '0', disabled)
## Examples ## Examples
**change default dns backend to 'unbound':** **change default dns backend to 'unbound':**
<pre><code> <pre><code>
Adblock detects the presence of an active unbound dns backend and the block lists will be automatically pulled in by unbound. Adblock deposits the sorted and filtered block list (adb_list.overall) in '/var/lib/unbound' where unbound can find them in its jail.
The adblock script deposits the sorted and filtered block lists in '/var/lib/unbound' where unbound can find them in its jail. If you use manual configuration for unbound, then just include the following line in your 'server' clause:
If you use manual configuration for unbound, then just include the following line in your 'server:' clause:
include: "/var/lib/unbound/adb_list.*" include: "/var/lib/unbound/adb_list.overall"
</code></pre>
**change default dns backend to 'bind':**
<pre><code>
Adblock deposits the sorted and filtered block list (adb_list.overall) in '/var/lib/bind' where bind can find them.
To use the block list please modify the following bind configuration files:
change '/etc/bind/named.conf', in the 'options' namespace add:
response-policy { zone "rpz"; };
and at the end of the file add:
zone "rpz" {
type master;
file "/etc/bind/db.rpz";
allow-query { none; };
allow-transfer { none; };
};
create the new file '/etc/bind/db.rpz' and add:
$TTL 2h
$ORIGIN rpz.
@ SOA localhost. root.localhost. (1 6h 1h 1w 2h)
NS localhost.
$INCLUDE /var/lib/bind/adb_list.overall
</code></pre> </code></pre>
**configuration for different download utilities:** **configuration for different download utilities:**
@ -152,15 +176,15 @@ curl:
**receive adblock runtime information:** **receive adblock runtime information:**
<pre><code> <pre><code>
root@blackhole:~# /etc/init.d/adblock status /etc/init.d/adblock status
::: adblock runtime information ::: adblock runtime information
status : active status : active
adblock_version : 2.6.0 adblock_version : 2.8.0
blocked_domains : 113711 blocked_domains : 122827
fetch_info : wget (built-in) fetch_info : wget (built-in)
dns_backend : dnsmasq dns_backend : dnsmasq
last_rundate : 12.04.2017 13:08:26 last_rundate : 26.06.2017 17:00:27
system : LEDE Reboot SNAPSHOT r3900-399d5cf532 system : LEDE Reboot SNAPSHOT r4434-b91a38d647
</code></pre> </code></pre>
**cronjob for a regular block list update (/etc/crontabs/root):** **cronjob for a regular block list update (/etc/crontabs/root):**
@ -186,7 +210,7 @@ This entry does not block:
<pre><code> <pre><code>
here.com here.com
This entry removes the following (sub)domains from the block lists: This entry removes the following (sub)domains from the block list:
maps.here.com maps.here.com
here.com here.com
@ -195,22 +219,21 @@ This entry does not remove:
www.adwhere.com www.adwhere.com
</code></pre> </code></pre>
**query active block lists for a certain (sub-)domain, e.g. for whitelisting:** **query active block list for a certain (sub-)domain, e.g. for whitelisting:**
<pre><code> <pre><code>
/etc/init.d/adblock query example.www.doubleclick.net /etc/init.d/adblock query example.www.doubleclick.net
::: distinct results for domain 'example.www.doubleclick.net' ::: results for (sub-)domain 'example.www.doubleclick.net' (max. 5)
no match - no match
::: distinct results for domain 'www.doubleclick.net' ::: results for (sub-)domain 'www.doubleclick.net' (max. 5)
adb_list.sysctl : www.doubleclick.net - no match
::: distinct results for domain 'doubleclick.net' ::: results for (sub-)domain 'doubleclick.net' (max. 5)
adb_list.adaway : ad-g.doubleclick.net + doubleclick.net
adb_list.securemecca : 1168945.fls.doubleclick.net + feedads.g.doubleclick.net
adb_list.sysctl : 1435575.fls.doubleclick.net + survey.g.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 (sub-)domain it returns the first five relevant results.
In the example above whitelist "www.doubleclick.net" to free the submitted domain. In the example above whitelist "doubleclick.net" to free the submitted domain.
</code></pre> </code></pre>
**add a new block list source:** **add a new block list source:**

View file

@ -6,7 +6,7 @@ config adblock 'global'
option adb_debug '0' option adb_debug '0'
option adb_forcesrt '0' option adb_forcesrt '0'
option adb_forcedns '0' option adb_forcedns '0'
option adb_iface 'wan' option adb_iface 'wan wan6'
option adb_triggerdelay '2' option adb_triggerdelay '2'
option adb_whitelist '/etc/adblock/adblock.whitelist' option adb_whitelist '/etc/adblock/adblock.whitelist'
option adb_whitelist_rset '\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}' option adb_whitelist_rset '\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}'

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.7.1" adb_ver="2.8.0"
adb_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')" adb_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
adb_enabled=1 adb_enabled=1
adb_debug=0 adb_debug=0
@ -24,8 +24,9 @@ adb_whitelist="/etc/adblock/adblock.whitelist"
adb_whitelist_rset="\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}" adb_whitelist_rset="\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}"
adb_fetch="/usr/bin/wget" adb_fetch="/usr/bin/wget"
adb_fetchparm="--quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 --no-check-certificate -O" adb_fetchparm="--quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 --no-check-certificate -O"
adb_dnslist="dnsmasq unbound" adb_dnslist="dnsmasq unbound named"
adb_dnsprefix="adb_list" adb_dnsprefix="adb_list"
adb_dnsfile="${adb_dnsprefix}.overall"
adb_rtfile="/tmp/adb_runtime.json" adb_rtfile="/tmp/adb_runtime.json"
adb_sources="" adb_sources=""
adb_src_cat_shalla="" adb_src_cat_shalla=""
@ -113,6 +114,13 @@ f_envload()
adb_dnsformat="awk '{print \"local-zone: \042\"\$0\"\042 static\"}'" adb_dnsformat="awk '{print \"local-zone: \042\"\$0\"\042 static\"}'"
break 2 break 2
;; ;;
named)
adb_dns="${dns}"
adb_dnsdir="${adb_dnsdir:="/var/lib/bind"}"
adb_dnshidedir="${adb_dnsdir}/.adb_hidden"
adb_dnsformat="awk '{print \"\"\$0\" IN CNAME .\n*.\"\$0\" IN CNAME .\"}'"
break 2
;;
esac esac
fi fi
done done
@ -160,7 +168,7 @@ f_envcheck()
# #
if [ ${adb_enabled} -ne 1 ] if [ ${adb_enabled} -ne 1 ]
then then
if [ -n "$(ls -dA "${adb_dnsdir}/${adb_dnsprefix}"* 2>/dev/null)" ] if [ -s "${adb_dnsdir}/${adb_dnsfile}" ]
then then
f_rmdns f_rmdns
f_dnsrestart f_dnsrestart
@ -291,18 +299,14 @@ f_list()
fi fi
;; ;;
restore) restore)
if [ ${adb_backup} -eq 1 ] && [ -d "${adb_backupdir}" ] if [ ${adb_backup} -eq 1 ] && [ -d "${adb_backupdir}" ] &&
[ -f "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz" ]
then then
rm -f "${adb_dnsdir}/${adb_dnsprefix}.${src_name}" gunzip -cf "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz" > "${adb_tmpfile}"
if [ -f "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz" ] adb_rc=${?}
then
gunzip -cf "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz" > "${adb_tmpfile}"
adb_rc=${?}
fi
fi fi
;; ;;
remove) remove)
rm -f "${adb_dnsdir}/${adb_dnsprefix}.${src_name}"
if [ -d "${adb_backupdir}" ] if [ -d "${adb_backupdir}" ]
then then
rm -f "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz" rm -f "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz"
@ -312,9 +316,9 @@ f_list()
format) format)
if [ -s "${adb_tmpdir}/tmp.whitelist" ] if [ -s "${adb_tmpdir}/tmp.whitelist" ]
then then
grep -vf "${adb_tmpdir}/tmp.whitelist" "${adb_tmpfile}" | eval "${adb_dnsformat}" > "${adb_dnsfile}" grep -vf "${adb_tmpdir}/tmp.whitelist" "${adb_tmpfile}" | eval "${adb_dnsformat}" >> "${adb_tmpdir}/${adb_dnsfile}"
else else
eval "${adb_dnsformat}" "${adb_tmpfile}" > "${adb_dnsfile}" eval "${adb_dnsformat}" "${adb_tmpfile}" >> "${adb_tmpdir}/${adb_dnsfile}"
fi fi
adb_rc=${?} adb_rc=${?}
;; ;;
@ -326,20 +330,18 @@ f_list()
# #
f_switch() f_switch()
{ {
local source target status mode="${1}"
if [ -d "${adb_dnshidedir}" ] if [ -d "${adb_dnshidedir}" ]
then then
local source target status mode="${1}" if [ -s "${adb_dnsdir}/${adb_dnsfile}" ] && [ "${mode}" = "suspend" ]
local dns_active="$(find "${adb_dnsdir}" -maxdepth 1 -type f -name "${adb_dnsprefix}*" -print)"
local dns_passive="$(find "${adb_dnshidedir}" -maxdepth 1 -type f -name "${adb_dnsprefix}*" -print)"
if [ -n "${dns_active}" ] && [ "${mode}" = "suspend" ]
then then
source="${adb_dnsdir}/${adb_dnsprefix}" source="${adb_dnsdir}/${adb_dnsfile}"
target="${adb_dnshidedir}" target="${adb_dnshidedir}"
status="suspended" status="suspended"
elif [ -n "${dns_passive}" ] && [ "${mode}" = "resume" ] elif [ -s "${adb_dnshidedir}/${adb_dnsfile}" ] && [ "${mode}" = "resume" ]
then then
source="${adb_dnshidedir}/${adb_dnsprefix}" source="${adb_dnshidedir}/${adb_dnsfile}"
target="${adb_dnsdir}" target="${adb_dnsdir}"
status="resumed" status="resumed"
fi fi
@ -352,18 +354,17 @@ f_switch()
fi fi
} }
# f_query: query block lists for certain (sub-)domains # f_query: query block list for certain (sub-)domains
# #
f_query() f_query()
{ {
local search result cnt local search result cnt
local domain="${1}" local domain="${1}"
local tld="${domain#*.}" local tld="${domain#*.}"
local dns_active="$(find "${adb_dnsdir}" -maxdepth 1 -type f -name "${adb_dnsprefix}*" -print)"
if [ -z "${dns_active}" ] if [ ! -s "${adb_dnsdir}/${adb_dnsfile}" ]
then then
printf "%s\n" "::: no active block lists found, please start / resume adblock first" printf "%s\n" "::: no active block list found, please start / resume 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, e.g. 'www.abc.xyz'" printf "%s\n" "::: invalid domain input, please submit a specific (sub-)domain, e.g. 'www.abc.xyz'"
@ -372,9 +373,9 @@ f_query()
while [ "${domain}" != "${tld}" ] while [ "${domain}" != "${tld}" ]
do do
search="${domain//./\.}" search="${domain//./\.}"
result="$(grep -Hm1 "[/\"\.]${search}[/\"]" "${adb_dnsprefix}"* | awk -F ':|=|/|\"' '{printf(" %-20s : %s\n",$1,$4)}')" result="$(grep -Hm5 "[/\"\.]${search}[/\"]" "${adb_dnsfile}" | awk -F ':|=|/|\"' '{printf(" + %s\n",$4)}')"
printf "%s\n" "::: distinct results for domain '${domain}'" printf "%s\n" "::: results for (sub-)domain '${domain}' (max. 5)"
printf "%s\n" "${result:=" no match"}" printf "%s\n" "${result:=" - no match"}"
domain="${tld}" domain="${tld}"
tld="${domain#*.}" tld="${domain#*.}"
done done
@ -389,14 +390,10 @@ f_status()
if [ -s "${adb_rtfile}" ] if [ -s "${adb_rtfile}" ]
then then
local dns_active="$(find "${adb_dnsdir}" -maxdepth 1 -type f -name "${adb_dnsprefix}*" -print)" if [ -s "${adb_dnsdir}/${adb_dnsfile}" ]
local dns_passive="$(find "${adb_dnshidedir}" -maxdepth 1 -type f -name "${adb_dnsprefix}*" -print)"
if [ -n "${dns_active}" ]
then then
value="active" value="active"
elif [ -n "${dns_passive}" ] || [ -z "${dns_active}" ] else
then
value="no domains blocked" value="no domains blocked"
fi fi
printf "%s\n" "::: adblock runtime information" printf "%s\n" "::: adblock runtime information"
@ -425,7 +422,7 @@ f_log()
then then
logger -t "adblock-[${adb_ver}] ${class}" "Please check 'https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md' (${adb_sysver})" logger -t "adblock-[${adb_ver}] ${class}" "Please check 'https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md' (${adb_sysver})"
f_rmtemp f_rmtemp
if [ -n "$(ls -dA "${adb_dnsdir}/${adb_dnsprefix}"* 2>/dev/null)" ] if [ -s "${adb_dnsdir}/${adb_dnsfile}" ]
then then
f_rmdns f_rmdns
f_dnsrestart f_dnsrestart
@ -439,7 +436,7 @@ f_log()
# #
f_main() f_main()
{ {
local src_name src_rset shalla_archive enabled url cnt sum_cnt=0 local src_name src_rset shalla_archive enabled url cnt=0
local mem_total="$(awk '/^MemTotal/ {print int($2/1000)}' "/proc/meminfo")" local mem_total="$(awk '/^MemTotal/ {print int($2/1000)}' "/proc/meminfo")"
f_log "info " "start adblock processing ..." f_log "info " "start adblock processing ..."
@ -450,10 +447,9 @@ f_main()
eval "enabled=\"\${enabled_${src_name}}\"" eval "enabled=\"\${enabled_${src_name}}\""
eval "url=\"\${adb_src_${src_name}}\"" eval "url=\"\${adb_src_${src_name}}\""
eval "src_rset=\"\${adb_src_rset_${src_name}}\"" eval "src_rset=\"\${adb_src_rset_${src_name}}\""
adb_dnsfile="${adb_tmpdir}/${adb_dnsprefix}.${src_name}"
> "${adb_tmpload}" > "${adb_tmpload}"
> "${adb_tmpfile}" > "${adb_tmpfile}"
adb_rc=0 adb_rc=4
# basic pre-checks # basic pre-checks
# #
@ -468,7 +464,6 @@ f_main()
# #
if [ ${adb_manmode} -eq 1 ] && [ -z "${adb_action}" ] if [ ${adb_manmode} -eq 1 ] && [ -z "${adb_action}" ]
then then
adb_rc=4
f_list restore f_list restore
if [ ${adb_rc} -eq 0 ] && [ -s "${adb_tmpfile}" ] if [ ${adb_rc} -eq 0 ] && [ -s "${adb_tmpfile}" ]
then then
@ -479,7 +474,7 @@ f_main()
# download block list # download block list
# #
if [ "${src_name}" = "blacklist" ] if [ "${src_name}" = "blacklist" ] && [ -s "${url}" ]
then then
cat "${url}" > "${adb_tmpload}" cat "${url}" > "${adb_tmpload}"
adb_rc=${?} adb_rc=${?}
@ -542,25 +537,20 @@ f_main()
# overall sort # overall sort
# #
for src_name in $(ls -dASr "${adb_tmpdir}/${adb_dnsprefix}"* 2>/dev/null) if [ ${mem_total} -ge 64 ] || [ ${adb_forcesrt} -eq 1 ]
do then
if [ ${mem_total} -ge 64 ] || [ ${adb_forcesrt} -eq 1 ] if [ -s "${adb_tmpdir}/${adb_dnsfile}" ]
then then
if [ -s "${adb_tmpdir}/blocklist.overall" ] sort -u "${adb_tmpdir}/${adb_dnsfile}" > "${adb_dnsdir}/${adb_dnsfile}"
then else
sort "${adb_tmpdir}/blocklist.overall" "${adb_tmpdir}/blocklist.overall" "${src_name}" | uniq -u > "${adb_tmpdir}/tmp.blocklist" mv -f "${adb_tmpdir}/${adb_dnsfile}" "${adb_dnsdir}" 2>/dev/null
mv -f "${adb_tmpdir}/tmp.blocklist" "${src_name}"
fi
cat "${src_name}" >> "${adb_tmpdir}/blocklist.overall"
fi fi
cnt="$(wc -l < "${src_name}")" cnt="$(wc -l < "${adb_dnsdir}/${adb_dnsfile}")"
sum_cnt=$((sum_cnt + cnt)) fi
done
# restart the dns backend and export runtime information # restart the dns backend and export runtime information
# #
mv -f "${adb_tmpdir}/${adb_dnsprefix}"* "${adb_dnsdir}" 2>/dev/null chown "${adb_dns}":"${adb_dns}" "${adb_dnsdir}/${adb_dnsfile}" 2>/dev/null
chown "${adb_dns}":"${adb_dns}" "${adb_dnsdir}/${adb_dnsprefix}"* 2>/dev/null
f_rmtemp f_rmtemp
f_dnsrestart f_dnsrestart
if [ ${?} -eq 0 ] if [ ${?} -eq 0 ]
@ -568,16 +558,16 @@ f_main()
json_init json_init
json_add_object "data" json_add_object "data"
json_add_string "adblock_version" "${adb_ver}" json_add_string "adblock_version" "${adb_ver}"
json_add_string "blocked_domains" "${sum_cnt}" json_add_string "blocked_domains" "${cnt}"
json_add_string "fetch_info" "${adb_fetchinfo}" json_add_string "fetch_info" "${adb_fetchinfo}"
json_add_string "dns_backend" "${adb_dns}" json_add_string "dns_backend" "${adb_dns}"
json_add_string "last_rundate" "$(/bin/date "+%d.%m.%Y %H:%M:%S")" json_add_string "last_rundate" "$(/bin/date "+%d.%m.%Y %H:%M:%S")"
json_add_string "system" "${adb_sysver}" json_add_string "system" "${adb_sysver}"
json_close_object json_close_object
json_dump > "${adb_rtfile}" json_dump > "${adb_rtfile}"
f_log "info " "block lists with overall ${sum_cnt} domains loaded successfully (${adb_sysver})" f_log "info " "block list with overall ${cnt} domains loaded successfully (${adb_sysver})"
else else
f_log "error" "dns backend restart with active block lists failed" f_log "error" "dns backend restart with active block list failed"
fi fi
} }