|
|
@ -10,7 +10,7 @@ |
|
|
|
# |
|
|
|
LC_ALL=C |
|
|
|
PATH="/usr/sbin:/usr/bin:/sbin:/bin" |
|
|
|
adb_ver="2.6.3" |
|
|
|
adb_ver="2.6.4" |
|
|
|
adb_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')" |
|
|
|
adb_enabled=1 |
|
|
|
adb_debug=0 |
|
|
@ -21,7 +21,7 @@ adb_backupdir="/mnt" |
|
|
|
adb_whitelist="/etc/adblock/adblock.whitelist" |
|
|
|
adb_whitelist_rset="\$1 ~/^([A-Za-z0-9_-]+\.){1,}[A-Za-z]+/{print tolower(\"^\"\$1\"\\\|[.]\"\$1)}" |
|
|
|
adb_fetch="/usr/bin/wget" |
|
|
|
adb_fetchparm="--no-config --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_dnsprefix="adb_list" |
|
|
|
adb_rtfile="/tmp/adb_runtime.json" |
|
|
@ -33,7 +33,7 @@ adb_action="${1}" |
|
|
|
# |
|
|
|
f_envload() |
|
|
|
{ |
|
|
|
local dns_up cnt=0 |
|
|
|
local services dns_up cnt=0 |
|
|
|
|
|
|
|
# source in system library |
|
|
|
# |
|
|
@ -45,37 +45,6 @@ f_envload() |
|
|
|
f_log "error" "system libraries not found" |
|
|
|
fi |
|
|
|
|
|
|
|
# set dns backend environment |
|
|
|
# |
|
|
|
while [ ${cnt} -le 20 ] |
|
|
|
do |
|
|
|
for dns in ${adb_dnslist} |
|
|
|
do |
|
|
|
dns_up="$(ubus -S call service list "{\"name\":\"${dns}\"}" | jsonfilter -l1 -e "@.${dns}.instances.*.running")" |
|
|
|
if [ "${dns_up}" = "true" ] |
|
|
|
then |
|
|
|
case "${dns}" in |
|
|
|
dnsmasq) |
|
|
|
adb_dns="dnsmasq" |
|
|
|
adb_dnsdir="/tmp/dnsmasq.d" |
|
|
|
adb_dnshidedir="${adb_dnsdir}/.adb_hidden" |
|
|
|
adb_dnsformat="awk '{print \"local=/\"\$0\"/\"}'" |
|
|
|
break 2 |
|
|
|
;; |
|
|
|
unbound) |
|
|
|
adb_dns="unbound" |
|
|
|
adb_dnsdir="/var/lib/unbound" |
|
|
|
adb_dnshidedir="${adb_dnsdir}/.adb_hidden" |
|
|
|
adb_dnsformat="awk '{print \"local-zone: \042\"\$0\"\042 static\"}'" |
|
|
|
break 2 |
|
|
|
;; |
|
|
|
esac |
|
|
|
fi |
|
|
|
done |
|
|
|
sleep 1 |
|
|
|
cnt=$((cnt+1)) |
|
|
|
done |
|
|
|
|
|
|
|
# parse global section by callback |
|
|
|
# |
|
|
|
config_cb() |
|
|
@ -94,7 +63,7 @@ f_envload() |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
# parse 'source' section |
|
|
|
# parse 'source' sections |
|
|
|
# |
|
|
|
parse_config() |
|
|
|
{ |
|
|
@ -115,6 +84,40 @@ f_envload() |
|
|
|
config_load adblock |
|
|
|
config_foreach parse_config source |
|
|
|
|
|
|
|
# set dns backend environment |
|
|
|
# |
|
|
|
while [ ${cnt} -le 20 ] |
|
|
|
do |
|
|
|
services="$(ubus -S call service list 2>/dev/null)" |
|
|
|
if [ -n "${services}" ] |
|
|
|
then |
|
|
|
for dns in ${adb_dnslist} |
|
|
|
do |
|
|
|
dns_up="$(printf "%s" "${services}" | jsonfilter -l1 -e "@.${dns}.instances.*.running")" |
|
|
|
if [ "${dns_up}" = "true" ] |
|
|
|
then |
|
|
|
case "${dns}" in |
|
|
|
dnsmasq) |
|
|
|
adb_dns="${dns}" |
|
|
|
adb_dnsdir="${adb_dnsdir:="/tmp/dnsmasq.d"}" |
|
|
|
adb_dnshidedir="${adb_dnsdir}/.adb_hidden" |
|
|
|
adb_dnsformat="awk '{print \"local=/\"\$0\"/\"}'" |
|
|
|
break 2 |
|
|
|
;; |
|
|
|
unbound) |
|
|
|
adb_dns="${dns}" |
|
|
|
adb_dnsdir="${adb_dnsdir:="/var/lib/unbound"}" |
|
|
|
adb_dnshidedir="${adb_dnsdir}/.adb_hidden" |
|
|
|
adb_dnsformat="awk '{print \"local-zone: \042\"\$0\"\042 static\"}'" |
|
|
|
break 2 |
|
|
|
;; |
|
|
|
esac |
|
|
|
fi |
|
|
|
done |
|
|
|
fi |
|
|
|
sleep 1 |
|
|
|
cnt=$((cnt+1)) |
|
|
|
done |
|
|
|
if [ -z "${adb_dns}" ] || [ -z "${adb_dnsformat}" ] || [ ! -x "$(command -v ${adb_dns})" ] || [ ! -d "${adb_dnsdir}" ] |
|
|
|
then |
|
|
|
f_log "error" "no active/supported DNS backend found" |
|
|
@ -171,7 +174,7 @@ f_envcheck() |
|
|
|
then |
|
|
|
if [ "$(readlink -fn "${adb_fetch}")" = "/usr/bin/wget-nossl" ] |
|
|
|
then |
|
|
|
adb_fetchparm="--no-config --quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 -O" |
|
|
|
adb_fetchparm="--quiet --no-cache --no-cookies --max-redirect=0 --timeout=10 -O" |
|
|
|
elif [ "$(readlink -fn "/bin/wget")" = "/bin/busybox" ] || [ "$(readlink -fn "${adb_fetch}")" = "/bin/busybox" ] |
|
|
|
then |
|
|
|
adb_fetch="/bin/busybox" |
|
|
|