adblock-fast: update to 1.1.1-1

* move reload/restart logic from json() to config_cache()
* improve fw4 restart decision logic
* no longer store reload/restart info in ubus/status json file
* rename variables pointing to run-time information
* create dns_set_output_values to reuse code in principal all and luci app
* improve append_url to store collected URLs in an alternative variable

Signed-off-by: Stan Grishin <stangri@melmac.ca>
This commit is contained in:
Stan Grishin 2023-12-15 02:41:38 +00:00
parent 6244ba5633
commit bab17f480c
2 changed files with 196 additions and 140 deletions

View file

@ -5,8 +5,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=adblock-fast PKG_NAME:=adblock-fast
PKG_VERSION:=1.1.0 PKG_VERSION:=1.1.1
PKG_RELEASE:=7 PKG_RELEASE:=1
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca> PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>
PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE:=GPL-3.0-or-later

View file

@ -56,8 +56,9 @@ readonly unboundFilter='s|^|local-zone: "|;s|$|" static|'
readonly A_TMP="/var/${packageName}.a.tmp" readonly A_TMP="/var/${packageName}.a.tmp"
readonly B_TMP="/var/${packageName}.b.tmp" readonly B_TMP="/var/${packageName}.b.tmp"
readonly SED_TMP="/var/${packageName}.sed.tmp" readonly SED_TMP="/var/${packageName}.sed.tmp"
readonly jsonFile="/dev/shm/$packageName-status.json" readonly runningConfigFile="/dev/shm/${packageName}.config"
readonly sharedMemoryError="/dev/shm/$packageName-error" readonly runningErrorFile="/dev/shm/${packageName}.error"
readonly runningStatusFile="/dev/shm/${packageName}.status"
readonly hostsFilter='/localhost/d;/^#/d;/^[^0-9]/d;s/^0\.0\.0\.0.//;s/^127\.0\.0\.1.//;s/[[:space:]]*#.*$//;s/[[:cntrl:]]$//;s/[[:space:]]//g;/[`~!@#\$%\^&\*()=+;:"'\'',<>?/\|[{}]/d;/]/d;/\./!d;/^$/d;/[^[:alnum:]_.-]/d;' readonly hostsFilter='/localhost/d;/^#/d;/^[^0-9]/d;s/^0\.0\.0\.0.//;s/^127\.0\.0\.1.//;s/[[:space:]]*#.*$//;s/[[:cntrl:]]$//;s/[[:space:]]//g;/[`~!@#\$%\^&\*()=+;:"'\'',<>?/\|[{}]/d;/]/d;/\./!d;/^$/d;/[^[:alnum:]_.-]/d;'
readonly domainsFilter='/^#/d;s/[[:space:]]*#.*$//;s/[[:space:]]*$//;s/[[:cntrl:]]$//;/[[:space:]]/d;/[`~!@#\$%\^&\*()=+;:"'\'',<>?/\|[{}]/d;/]/d;/\./!d;/^$/d;/[^[:alnum:]_.-]/d;' readonly domainsFilter='/^#/d;s/[[:space:]]*#.*$//;s/[[:space:]]*$//;s/[[:cntrl:]]$//;/[[:space:]]/d;/[`~!@#\$%\^&\*()=+;:"'\'',<>?/\|[{}]/d;/]/d;/\./!d;/^$/d;/[^[:alnum:]_.-]/d;'
readonly adBlockPlusFilter='/^#/d;/^!/d;s/[[:space:]]*#.*$//;s/^||//;s/\^$//;s/[[:space:]]*$//;s/[[:cntrl:]]$//;/[[:space:]]/d;/[`~!@#\$%\^&\*()=+;:"'\'',<>?/\|[{}]/d;/]/d;/\./!d;/^$/d;/[^[:alnum:]_.-]/d;' readonly adBlockPlusFilter='/^#/d;/^!/d;s/[[:space:]]*#.*$//;s/^||//;s/\^$//;s/[[:space:]]*$//;s/[[:cntrl:]]$//;/[[:space:]]/d;/[`~!@#\$%\^&\*()=+;:"'\'',<>?/\|[{}]/d;/]/d;/\./!d;/^$/d;/[^[:alnum:]_.-]/d;'
@ -76,6 +77,8 @@ readonly ipset="$(command -v ipset)"
readonly nft="$(command -v nft)" readonly nft="$(command -v nft)"
readonly canaryDomainsMozilla='use-application-dns.net' readonly canaryDomainsMozilla='use-application-dns.net'
readonly canaryDomainsiCloud='mask.icloud.com mask-h2.icloud.com' readonly canaryDomainsiCloud='mask.icloud.com mask-h2.icloud.com'
readonly triggersReload='parallel_downloads debug download_timeout allowed_domain blocked_domain allowed_url blocked_url dns config_update_enabled config_update_url dnsmasq_config_file_url curl_additional_param curl_max_file_size curl_retry'
readonly triggersRestart='compressed_cache compressed_cache_dir force_dns led force_dns_port'
dl_command= dl_command=
dl_flag= dl_flag=
@ -89,6 +92,7 @@ awk='awk'
load_environment_flag= load_environment_flag=
allowed_url= allowed_url=
blocked_url= blocked_url=
fw4_restart_flag=
# shellcheck disable=SC1091 # shellcheck disable=SC1091
. /lib/functions.sh . /lib/functions.sh
@ -117,12 +121,159 @@ check_smartdns() { command -v smartdns >/dev/null 2>&1; }
check_smartdns_ipset() { check_smartdns && check_ipset; } check_smartdns_ipset() { check_smartdns && check_ipset; }
check_smartdns_nftset() { check_smartdns && check_nft; } check_smartdns_nftset() { check_smartdns && check_nft; }
check_unbound() { command -v unbound >/dev/null 2>&1; } check_unbound() { command -v unbound >/dev/null 2>&1; }
config_cache() {
local param="$1" var="$2"
local _reload="$triggersReload"
local _restart="$triggersRestart"
local i ret
case "$param" in
create|set)
cp -f "/etc/config/${packageName}" "$runningConfigFile"
;;
get)
case "$var" in
trigger_fw4)
ret='false'
if [ -s "$runningConfigFile" ]; then
local UCI_CONFIG_DIR="${runningConfigFile%/*}"
is_fw4_restart_needed && ret='true'
fi
printf "%b" "$ret"
return
;;
trigger_service)
local old_allowed_url old_blocked_url
if [ ! -s "$runningConfigFile" ]; then
ret='on_boot'
else
for i in $_reload; do
local val_current val_old UCI_CONFIG_DIR
case "$i" in
allowed_url)
val_current="$allowed_url"
config_load "$runningConfigFile"
config_foreach append_url 'file_url' old_allowed_url old_blocked_url
val_old="$old_allowed_url"
;;
blocked_url)
val_current="$blocked_url"
config_load "$runningConfigFile"
config_foreach append_url 'file_url' old_allowed_url old_blocked_url
val_old="$old_blocked_url"
;;
*)
UCI_CONFIG_DIR=
val_current="$(uci_get "$packageName" 'config' "$i")"
UCI_CONFIG_DIR="${runningConfigFile%/*}"
val_old="$(uci_get "$packageName" 'config' "$i")"
;;
esac
if [ "$val_current" != "$val_old" ]; then
ret='download'
unset _restart
break
fi
done
for i in $_restart; do
local val_current val_old UCI_CONFIG_DIR
UCI_CONFIG_DIR=
val_current="$(uci_get "$packageName" 'config' "$i")"
UCI_CONFIG_DIR="${runningConfigFile%/*}"
val_old="$(uci_get "$packageName" 'config' "$i")"
if [ "$val_current" != "$val_old" ]; then
ret='restart'
break
fi
done
fi
printf "%b" "$ret"
return
;;
*)
local UCI_CONFIG_DIR="${runningConfigFile%/*}"
ret="$(uci_get "$packageName" 'config' "$var")"
printf "%b" "$ret"
return
;;
esac
;;
esac
}
debug() { local i j; for i in "$@"; do eval "j=\$$i"; echo "${i}: ${j} "; done; } debug() { local i j; for i in "$@"; do eval "j=\$$i"; echo "${i}: ${j} "; done; }
dns_set_output_values() {
case "$1" in
dnsmasq.addnhosts)
outputFilter="$dnsmasqAddnhostsFilter"
outputFile="$dnsmasqAddnhostsFile"
outputCache="$dnsmasqAddnhostsCache"
outputGzip="${compressed_cache_dir}/${dnsmasqAddnhostsGzip}"
if [ "$ipv6_enabled" -ne '0' ]; then
outputFilterIPv6="$dnsmasqAddnhostsFilterIPv6"
fi
;;
dnsmasq.conf)
outputFilter="$dnsmasqConfFilter"
outputFile="$dnsmasqConfFile"
outputCache="$dnsmasqConfCache"
outputGzip="${compressed_cache_dir}/${dnsmasqConfGzip}"
;;
dnsmasq.ipset)
outputFilter="$dnsmasqIpsetFilter"
outputFile="$dnsmasqIpsetFile"
outputCache="$dnsmasqIpsetCache"
outputGzip="${compressed_cache_dir}/${dnsmasqIpsetGzip}"
;;
dnsmasq.nftset)
if [ "$ipv6_enabled" -ne '0' ]; then
outputFilter="$dnsmasqNftsetFilterIPv6"
else
outputFilter="$dnsmasqNftsetFilter"
fi
outputFile="$dnsmasqNftsetFile"
outputCache="$dnsmasqNftsetCache"
outputGzip="${compressed_cache_dir}/${dnsmasqNftsetGzip}"
;;
dnsmasq.servers)
outputFilter="$dnsmasqServersFilter"
outputFile="$dnsmasqServersFile"
outputCache="$dnsmasqServersCache"
outputGzip="${compressed_cache_dir}/${dnsmasqServersGzip}"
;;
smartdns.domainset)
outputFilter="$smartdnsDomainSetFilter"
outputFile="$smartdnsDomainSetFile"
outputCache="$smartdnsDomainSetCache"
outputGzip="${compressed_cache_dir}/${smartdnsDomainSetGzip}"
outputConfig="$smartdnsDomainSetConfig"
;;
smartdns.ipset)
outputFilter="$smartdnsIpsetFilter"
outputFile="$smartdnsIpsetFile"
outputCache="$smartdnsIpsetCache"
outputGzip="${compressed_cache_dir}/${smartdnsIpsetGzip}"
outputConfig="$smartdnsIpsetConfig"
;;
smartdns.nftset)
outputFilter="$smartdnsNftsetFilter"
outputFile="$smartdnsNftsetFile"
outputCache="$smartdnsNftsetCache"
outputGzip="${compressed_cache_dir}/${smartdnsNftsetGzip}"
outputConfig="$smartdnsNftsetConfig"
;;
unbound.adb_list)
outputFilter="$unboundFilter"
outputFile="$unboundFile"
outputCache="$unboundCache"
outputGzip="$unboundGzip"
;;
esac
}
dnsmasq_hup() { killall -q -s HUP dnsmasq; } dnsmasq_hup() { killall -q -s HUP dnsmasq; }
dnsmasq_kill() { killall -q -s KILL dnsmasq; } dnsmasq_kill() { killall -q -s KILL dnsmasq; }
dnsmasq_restart() { /etc/init.d/dnsmasq restart >/dev/null 2>&1; } dnsmasq_restart() { /etc/init.d/dnsmasq restart >/dev/null 2>&1; }
is_enabled() { uci_get "$1" 'config' 'enabled' '0'; } is_enabled() { uci_get "$1" 'config' 'enabled' '0'; }
is_fw4_restart_needed() { is_fw4_restart_needed() {
[ "$fw4_restart_flag" = 'true' ] && return 0
local dns force_dns local dns force_dns
dns="$(uci_get "$packageName" 'config' 'dns' 'dnsmasq.servers')" dns="$(uci_get "$packageName" 'config' 'dns' 'dnsmasq.servers')"
force_dns="$(uci_get "$packageName" 'config' 'force_dns' '1')" force_dns="$(uci_get "$packageName" 'config' 'force_dns' '1')"
@ -199,39 +350,18 @@ json() {
# shellcheck disable=SC2124 # shellcheck disable=SC2124
local extras="$@" line local extras="$@" line
local status message error stats local status message error stats
local reload restart curReload curRestart
local ret i local ret i
if [ -s "$jsonFile" ]; then if [ -s "$runningStatusFile" ]; then
json_load_file "$jsonFile" 2>/dev/null json_load_file "$runningStatusFile" 2>/dev/null
json_select 'data' 2>/dev/null json_select 'data' 2>/dev/null
for i in status message error stats reload restart; do for i in status message error stats; do
json_get_var "$i" "$i" 2>/dev/null json_get_var "$i" "$i" 2>/dev/null
done done
fi fi
case "$action" in case "$action" in
get) get)
case "$param" in printf "%b" "$(eval echo "\$$param")"
triggers) return
# shellcheck disable=SC2154
curReload="$parallel_downloads $debug $download_timeout \
$allowed_domain $blocked_domain $allowed_url $blocked_url $dns \
$config_update_enabled $config_update_url $dnsmasq_config_file_url \
$curl_additional_param $curl_max_file_size $curl_retry"
# shellcheck disable=SC2154
curRestart="$compressed_cache $compressed_cache_dir $force_dns $led \
$force_dns_port"
if [ ! -s "$jsonFile" ]; then
ret='on_boot'
elif [ "$curReload" != "$reload" ]; then
ret='download'
elif [ "$curRestart" != "$restart" ]; then
ret='restart'
fi
printf "%b" "$ret"
return;;
*)
printf "%b" "$(eval echo "\$$param")"; return;;
esac
;; ;;
add) add)
line="$(eval echo "\$$param")" line="$(eval echo "\$$param")"
@ -241,25 +371,12 @@ json() {
case "$param" in case "$param" in
all) all)
unset status message error stats;; unset status message error stats;;
triggers)
unset reload restart;;
*) *)
unset "$param";; unset "$param";;
esac esac
;; ;;
set) set)
case "$param" in eval "$param"='${value}${extras:+|$extras}'
triggers)
reload="$parallel_downloads $debug $download_timeout \
$allowed_domain $blocked_domain $allowed_url $blocked_url $dns \
$config_update_enabled $config_update_url $dnsmasq_config_file_url \
$curl_additional_param $curl_max_file_size $curl_retry"
restart="$compressed_cache $compressed_cache_dir $force_dns $led \
$force_dns_port"
;;
*)
eval "$param"='${value}${extras:+|$extras}';;
esac
;; ;;
esac esac
json_init json_init
@ -269,11 +386,9 @@ json() {
json_add_string message "$message" json_add_string message "$message"
json_add_string error "$error" json_add_string error "$error"
json_add_string stats "$stats" json_add_string stats "$stats"
json_add_string reload "$reload"
json_add_string restart "$restart"
json_close_object json_close_object
mkdir -p "$(dirname "$jsonFile")" mkdir -p "${runningStatusFile%/*}"
json_dump > "$jsonFile" json_dump > "$runningStatusFile"
sync sync
} }
@ -475,16 +590,21 @@ load_network() {
} }
append_url() { append_url() {
local cfg="$1" var="$2" local cfg="$1" allow_var="${2:-allowed_url}" block_var="${3:-blocked_url}"
local old_value
local en action url local en action url
config_get_bool en "$cfg" enabled '1' config_get_bool en "$cfg" enabled '1'
config_get action "$cfg" action 'block' config_get action "$cfg" action 'block'
config_get url "$cfg" url config_get url "$cfg" url
if [ "$en" = '1' ]; then if [ "$en" = '1' ]; then
if [ "$action" = 'allow' ]; then if [ "$action" = 'allow' ]; then
allowed_url="${allowed_url:+$allowed_url }${url}" old_value=$(eval echo "\$$allow_var")
old_value="${old_value:+$old_value }${url}"
eval "$allow_var"="\$old_value"
else else
blocked_url="${blocked_url:+$blocked_url }${url}" old_value=$(eval echo "\$$block_var")
old_value="${old_value:+$old_value }${url}"
eval "$block_var"="\$old_value"
fi fi
fi fi
} }
@ -625,72 +745,7 @@ load_environment() {
compressed_cache_dir="/etc" compressed_cache_dir="/etc"
fi fi
case "$dns" in dns_set_output_values "$dns"
dnsmasq.addnhosts)
outputFilter="$dnsmasqAddnhostsFilter"
outputFile="$dnsmasqAddnhostsFile"
outputCache="$dnsmasqAddnhostsCache"
outputGzip="${compressed_cache_dir}/${dnsmasqAddnhostsGzip}"
if [ "$ipv6_enabled" -ne '0' ]; then
outputFilterIPv6="$dnsmasqAddnhostsFilterIPv6"
fi
;;
dnsmasq.conf)
outputFilter="$dnsmasqConfFilter"
outputFile="$dnsmasqConfFile"
outputCache="$dnsmasqConfCache"
outputGzip="${compressed_cache_dir}/${dnsmasqConfGzip}"
;;
dnsmasq.ipset)
outputFilter="$dnsmasqIpsetFilter"
outputFile="$dnsmasqIpsetFile"
outputCache="$dnsmasqIpsetCache"
outputGzip="${compressed_cache_dir}/${dnsmasqIpsetGzip}"
;;
dnsmasq.nftset)
if [ "$ipv6_enabled" -ne '0' ]; then
outputFilter="$dnsmasqNftsetFilterIPv6"
else
outputFilter="$dnsmasqNftsetFilter"
fi
outputFile="$dnsmasqNftsetFile"
outputCache="$dnsmasqNftsetCache"
outputGzip="${compressed_cache_dir}/${dnsmasqNftsetGzip}"
;;
dnsmasq.servers)
outputFilter="$dnsmasqServersFilter"
outputFile="$dnsmasqServersFile"
outputCache="$dnsmasqServersCache"
outputGzip="${compressed_cache_dir}/${dnsmasqServersGzip}"
;;
smartdns.domainset)
outputFilter="$smartdnsDomainSetFilter"
outputFile="$smartdnsDomainSetFile"
outputCache="$smartdnsDomainSetCache"
outputGzip="${compressed_cache_dir}/${smartdnsDomainSetGzip}"
outputConfig="$smartdnsDomainSetConfig"
;;
smartdns.ipset)
outputFilter="$smartdnsIpsetFilter"
outputFile="$smartdnsIpsetFile"
outputCache="$smartdnsIpsetCache"
outputGzip="${compressed_cache_dir}/${smartdnsIpsetGzip}"
outputConfig="$smartdnsIpsetConfig"
;;
smartdns.nftset)
outputFilter="$smartdnsNftsetFilter"
outputFile="$smartdnsNftsetFile"
outputCache="$smartdnsNftsetCache"
outputGzip="${compressed_cache_dir}/${smartdnsNftsetGzip}"
outputConfig="$smartdnsNftsetConfig"
;;
unbound.adb_list)
outputFilter="$unboundFilter"
outputFile="$unboundFile"
outputCache="$unboundCache"
outputGzip="$unboundGzip"
;;
esac
[ "$dns" = 'dnsmasq.addnhosts' ] || rm -f "$dnsmasqAddnhostsFile" "$dnsmasqAddnhostsCache" "${compressed_cache_dir}/${dnsmasqAddnhostsGzip}" [ "$dns" = 'dnsmasq.addnhosts' ] || rm -f "$dnsmasqAddnhostsFile" "$dnsmasqAddnhostsCache" "${compressed_cache_dir}/${dnsmasqAddnhostsGzip}"
[ "$dns" = 'dnsmasq.conf' ] || rm -f "$dnsmasqConfFile" "$dnsmasqConfCache" "${compressed_cache_dir}/${dnsmasqConfGzip}" [ "$dns" = 'dnsmasq.conf' ] || rm -f "$dnsmasqConfFile" "$dnsmasqConfCache" "${compressed_cache_dir}/${dnsmasqConfGzip}"
@ -702,9 +757,9 @@ load_environment() {
[ "$dns" = 'smartdns.nftset' ] || rm -f "$smartdnsNftsetFile" "$smartdnsNftsetCache" "${compressed_cache_dir}/${smartdnsNftsetGzip}" "$smartdnsNftsetConfig" [ "$dns" = 'smartdns.nftset' ] || rm -f "$smartdnsNftsetFile" "$smartdnsNftsetCache" "${compressed_cache_dir}/${smartdnsNftsetGzip}" "$smartdnsNftsetConfig"
[ "$dns" = 'unbound.adb_list' ] || rm -f "$unboundFile" "$unboundCache" "$unboundGzip" [ "$dns" = 'unbound.adb_list' ] || rm -f "$unboundFile" "$unboundCache" "$unboundGzip"
for i in "$jsonFile" "$outputFile" "$outputCache" "$outputGzip" "$outputConfig"; do for i in "$runningConfigFile" "$runningErrorFile" "$runningStatusFile" "$outputFile" "$outputCache" "$outputGzip" "$outputConfig"; do
[ -n "$i" ] || continue [ -n "$i" ] || continue
if ! mkdir -p "$(dirname "$i")"; then if ! mkdir -p "${i%/*}"; then
if [ "$param" != 'quiet' ]; then if [ "$param" != 'quiet' ]; then
json add error 'errorOutputDirCreate' "$i" json add error 'errorOutputDirCreate' "$i"
output "${_ERROR_}: $(get_text 'errorOutputDirCreate' "$i")!\\n" output "${_ERROR_}: $(get_text 'errorOutputDirCreate' "$i")!\\n"
@ -1045,7 +1100,7 @@ process_file_url() {
if is_https_url "$url" && [ -z "$isSSLSupported" ]; then if is_https_url "$url" && [ -z "$isSSLSupported" ]; then
output 1 "$_FAIL_" output 1 "$_FAIL_"
output 2 "[DL] $type $label $__FAIL__\\n" output 2 "[DL] $type $label $__FAIL__\\n"
echo "errorNoSSLSupport|${1}" >> "$sharedMemoryError" echo "errorNoSSLSupport|${1}" >> "$runningErrorFile"
return 0 return 0
fi fi
while [ -z "$R_TMP" ] || [ -e "$R_TMP" ]; do while [ -z "$R_TMP" ] || [ -e "$R_TMP" ]; do
@ -1055,7 +1110,7 @@ process_file_url() {
[ ! -s "$R_TMP" ]; then [ ! -s "$R_TMP" ]; then
output 1 "$_FAIL_" output 1 "$_FAIL_"
output 2 "[DL] $type $label $__FAIL__\\n" output 2 "[DL] $type $label $__FAIL__\\n"
echo "errorDownloadingList|${url}" >> "$sharedMemoryError" echo "errorDownloadingList|${url}" >> "$runningErrorFile"
else else
append_newline "$R_TMP" append_newline "$R_TMP"
[ -n "$cfg" ] && new_size="$(get_local_filesize "$R_TMP")" [ -n "$cfg" ] && new_size="$(get_local_filesize "$R_TMP")"
@ -1073,7 +1128,7 @@ process_file_url() {
*) *)
output 1 "$_FAIL_" output 1 "$_FAIL_"
output 2 "[DL] $type $label $__FAIL__\\n" output 2 "[DL] $type $label $__FAIL__\\n"
echo "errorDetectingFileType|${url}" >> "$sharedMemoryError" echo "errorDetectingFileType|${url}" >> "$runningErrorFile"
rm -f "$R_TMP" rm -f "$R_TMP"
return 0 return 0
;; ;;
@ -1084,7 +1139,7 @@ process_file_url() {
if [ ! -s "$R_TMP" ]; then if [ ! -s "$R_TMP" ]; then
output 1 "$_FAIL_" output 1 "$_FAIL_"
output 2 "[DL] $type $label ($format) $__FAIL__\\n" output 2 "[DL] $type $label ($format) $__FAIL__\\n"
echo "errorParsingList|${url}" >> "$sharedMemoryError" echo "errorParsingList|${url}" >> "$runningErrorFile"
else else
append_newline "$R_TMP" append_newline "$R_TMP"
cat "${R_TMP}" >> "$D_TMP" cat "${R_TMP}" >> "$D_TMP"
@ -1111,13 +1166,13 @@ download_dnsmasq_file() {
fi fi
touch "$A_TMP" "$B_TMP" "$SED_TMP" touch "$A_TMP" "$B_TMP" "$SED_TMP"
output 1 'Downloading dnsmasq file ' output 1 'Downloading dnsmasq file '
rm -f "$sharedMemoryError" rm -f "$runningErrorFile"
process_file_url '' "$dnsmasq_config_file_url" 'file' process_file_url '' "$dnsmasq_config_file_url" 'file'
if [ -s "$sharedMemoryError" ]; then if [ -s "$runningErrorFile" ]; then
while IFS= read -r line; do while IFS= read -r line; do
json add error "$line" json add error "$line"
done < "$sharedMemoryError" done < "$runningErrorFile"
rm -f "$sharedMemoryError" rm -f "$runningErrorFile"
fi fi
output 2 'Moving dnsmasq file ' output 2 'Moving dnsmasq file '
if mv "$B_TMP" "$outputFile"; then if mv "$B_TMP" "$outputFile"; then
@ -1176,7 +1231,7 @@ download_lists() {
fi fi
touch "$A_TMP" "$B_TMP" "$SED_TMP" touch "$A_TMP" "$B_TMP" "$SED_TMP"
output 1 'Downloading lists ' output 1 'Downloading lists '
rm -f "$sharedMemoryError" rm -f "$runningErrorFile"
config_load "$packageName" config_load "$packageName"
config_foreach load_validate_file_url_section 'file_url' process_file_url_wrapper config_foreach load_validate_file_url_section 'file_url' process_file_url_wrapper
wait wait
@ -1186,11 +1241,11 @@ download_lists() {
fi fi
output 1 '\n' output 1 '\n'
if [ -s "$sharedMemoryError" ]; then if [ -s "$runningErrorFile" ]; then
while IFS= read -r line; do while IFS= read -r line; do
json add error "$line" json add error "$line"
done < "$sharedMemoryError" done < "$runningErrorFile"
rm -f "$sharedMemoryError" rm -f "$runningErrorFile"
fi fi
if [ "$canary_domains_icloud" -ne '0' ]; then if [ "$canary_domains_icloud" -ne '0' ]; then
@ -1421,7 +1476,7 @@ adb_allow() {
output 2 "Committing changes to config " output 2 "Committing changes to config "
if uci_commit "$packageName"; then if uci_commit "$packageName"; then
allowed_domain="$(uci_get "$packageName" 'config' 'allowed_domain')" allowed_domain="$(uci_get "$packageName" 'config' 'allowed_domain')"
json set triggers config_cache 'create'
json set stats "$serviceName is blocking $(wc -l < "$outputFile") domains (with ${dns})" json set stats "$serviceName is blocking $(wc -l < "$outputFile") domains (with ${dns})"
output_ok; output_ok;
if [ "$dns" = 'dnsmasq.ipset' ]; then if [ "$dns" = 'dnsmasq.ipset' ]; then
@ -1463,7 +1518,7 @@ adb_allow() {
output 2 "Committing changes to config " output 2 "Committing changes to config "
if uci_commit "$packageName"; then if uci_commit "$packageName"; then
allowed_domain="$(uci_get "$packageName" 'config' 'allowed_domain')" allowed_domain="$(uci_get "$packageName" 'config' 'allowed_domain')"
json set triggers config_cache 'create'
json set stats "$serviceName is blocking $(wc -l < "$outputFile") domains (with ${dns})" json set stats "$serviceName is blocking $(wc -l < "$outputFile") domains (with ${dns})"
output_ok; output_ok;
output 2 "Restarting Unbound " output 2 "Restarting Unbound "
@ -1496,7 +1551,7 @@ adb_allow() {
output 2 "Committing changes to config " output 2 "Committing changes to config "
if uci_commit "$packageName"; then if uci_commit "$packageName"; then
allowed_domain="$(uci_get "$packageName" 'config' 'allowed_domain')" allowed_domain="$(uci_get "$packageName" 'config' 'allowed_domain')"
json set triggers config_cache 'create'
json set stats "$serviceName is blocking $(wc -l < "$outputFile") domains (with ${dns})" json set stats "$serviceName is blocking $(wc -l < "$outputFile") domains (with ${dns})"
output_ok; output_ok;
output 2 "Restarting Unbound " output 2 "Restarting Unbound "
@ -1666,11 +1721,12 @@ adb_start() {
load_environment "$validation_result" "$param" || return 1 load_environment "$validation_result" "$param" || return 1
status="$(json get status)" status="$(json get 'status')"
error="$(json get error)" error="$(json get 'error')"
message="$(json get message)" message="$(json get 'message')"
stats="$(json get stats)" stats="$(json get 'stats')"
action="$(json get triggers)" action="$(config_cache get 'trigger_service')"
fw4_restart_flag="$(config_cache get 'trigger_fw4')"
if [ "$action" = 'on_boot' ] || [ "$param" = 'on_boot' ]; then if [ "$action" = 'on_boot' ] || [ "$param" = 'on_boot' ]; then
if cache 'test_gzip' || cache 'test'; then if cache 'test_gzip' || cache 'test'; then
@ -1696,7 +1752,7 @@ adb_start() {
fi fi
json del all json del all
json set triggers config_cache 'create'
if [ "$action" = 'restore' ]; then if [ "$action" = 'restore' ]; then
output 0 "Starting $serviceName... " output 0 "Starting $serviceName... "