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

@@ -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"
}