|
@ -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.6.2" |
|
|
|
|
|
|
|
|
adb_ver="2.6.3" |
|
|
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 |
|
@ -25,6 +25,9 @@ adb_fetchparm="--no-config --quiet --no-cache --no-cookies --max-redirect=0 --ti |
|
|
adb_dnslist="dnsmasq unbound" |
|
|
adb_dnslist="dnsmasq unbound" |
|
|
adb_dnsprefix="adb_list" |
|
|
adb_dnsprefix="adb_list" |
|
|
adb_rtfile="/tmp/adb_runtime.json" |
|
|
adb_rtfile="/tmp/adb_runtime.json" |
|
|
|
|
|
adb_sources="" |
|
|
|
|
|
adb_src_cat_shalla="" |
|
|
|
|
|
adb_action="${1}" |
|
|
|
|
|
|
|
|
# f_envload: load adblock environment |
|
|
# f_envload: load adblock environment |
|
|
# |
|
|
# |
|
@ -72,10 +75,6 @@ f_envload() |
|
|
sleep 1 |
|
|
sleep 1 |
|
|
cnt=$((cnt+1)) |
|
|
cnt=$((cnt+1)) |
|
|
done |
|
|
done |
|
|
if [ -z "${adb_dns}" ] |
|
|
|
|
|
then |
|
|
|
|
|
f_log "error" "no active/supported DNS backend found" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# parse global section by callback |
|
|
# parse global section by callback |
|
|
# |
|
|
# |
|
@ -116,6 +115,11 @@ f_envload() |
|
|
config_load adblock |
|
|
config_load adblock |
|
|
config_foreach parse_config source |
|
|
config_foreach parse_config source |
|
|
|
|
|
|
|
|
|
|
|
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" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
# force dns to local resolver |
|
|
# force dns to local resolver |
|
|
# |
|
|
# |
|
|
if [ ${adb_forcedns} -eq 1 ] && [ -z "$(uci -q get firewall.adblock_dns)" ] |
|
|
if [ ${adb_forcedns} -eq 1 ] && [ -z "$(uci -q get firewall.adblock_dns)" ] |
|
@ -134,7 +138,7 @@ f_envload() |
|
|
if [ -n "$(uci -q changes firewall)" ] |
|
|
if [ -n "$(uci -q changes firewall)" ] |
|
|
then |
|
|
then |
|
|
uci -q commit firewall |
|
|
uci -q commit firewall |
|
|
if [ $(/etc/init.d/firewall enabled; printf ${?}) -eq 0 ] |
|
|
|
|
|
|
|
|
if [ $(/etc/init.d/firewall enabled; printf "%u" ${?}) -eq 0 ] |
|
|
then |
|
|
then |
|
|
/etc/init.d/firewall reload >/dev/null 2>&1 |
|
|
/etc/init.d/firewall reload >/dev/null 2>&1 |
|
|
fi |
|
|
fi |
|
@ -383,7 +387,7 @@ f_status() |
|
|
json_get_keys keylist |
|
|
json_get_keys keylist |
|
|
for key in ${keylist} |
|
|
for key in ${keylist} |
|
|
do |
|
|
do |
|
|
json_get_var value ${key} |
|
|
|
|
|
|
|
|
json_get_var value "${key}" |
|
|
printf " %-15s : %s\n" "${key}" "${value}" |
|
|
printf " %-15s : %s\n" "${key}" "${value}" |
|
|
done |
|
|
done |
|
|
fi |
|
|
fi |
|
@ -421,6 +425,7 @@ f_main() |
|
|
mem_total="$(awk '$1 ~ /^MemTotal/ {printf $2}' "/proc/meminfo" 2>/dev/null)" |
|
|
mem_total="$(awk '$1 ~ /^MemTotal/ {printf $2}' "/proc/meminfo" 2>/dev/null)" |
|
|
|
|
|
|
|
|
f_log "info " "start adblock processing ..." |
|
|
f_log "info " "start adblock processing ..." |
|
|
|
|
|
f_log "debug" "action: ${adb_action}, backup: ${adb_backup}, dns: ${adb_dns}, fetch: ${adb_fetchinfo}, memory: ${mem_total}, force srt/dns: ${adb_forcesrt}/${adb_forcedns}" |
|
|
> "${adb_rtfile}" |
|
|
> "${adb_rtfile}" |
|
|
for src_name in ${adb_sources} |
|
|
for src_name in ${adb_sources} |
|
|
do |
|
|
do |
|
@ -434,6 +439,7 @@ f_main() |
|
|
|
|
|
|
|
|
# basic pre-checks |
|
|
# basic pre-checks |
|
|
# |
|
|
# |
|
|
|
|
|
f_log "debug" "name: ${src_name}, enabled: ${enabled}, url: ${url}, rset: ${src_rset}" |
|
|
if [ "${enabled}" != "1" ] || [ -z "${url}" ] || [ -z "${src_rset}" ] |
|
|
if [ "${enabled}" != "1" ] || [ -z "${url}" ] || [ -z "${src_rset}" ] |
|
|
then |
|
|
then |
|
|
f_list remove |
|
|
f_list remove |
|
@ -442,7 +448,6 @@ f_main() |
|
|
|
|
|
|
|
|
# download block list |
|
|
# download block list |
|
|
# |
|
|
# |
|
|
f_log "debug" "name: ${src_name}, enabled: ${enabled}, backup: ${adb_backup}, dns: ${adb_dns}, fetch: ${adb_fetchinfo}, memory: ${mem_total}, force srt/dns: ${adb_forcesrt}/${adb_forcedns}" |
|
|
|
|
|
if [ "${src_name}" = "blacklist" ] |
|
|
if [ "${src_name}" = "blacklist" ] |
|
|
then |
|
|
then |
|
|
cat "${url}" 2>/dev/null > "${adb_tmpload}" |
|
|
cat "${url}" 2>/dev/null > "${adb_tmpload}" |
|
@ -456,7 +461,7 @@ f_main() |
|
|
then |
|
|
then |
|
|
for category in ${adb_src_cat_shalla} |
|
|
for category in ${adb_src_cat_shalla} |
|
|
do |
|
|
do |
|
|
tar -xOzf "${shalla_archive}" BL/${category}/domains >> "${adb_tmpload}" |
|
|
|
|
|
|
|
|
tar -xOzf "${shalla_archive}" "BL/${category}/domains" >> "${adb_tmpload}" |
|
|
adb_rc=${?} |
|
|
adb_rc=${?} |
|
|
if [ ${adb_rc} -ne 0 ] |
|
|
if [ ${adb_rc} -ne 0 ] |
|
|
then |
|
|
then |
|
@ -498,7 +503,7 @@ f_main() |
|
|
then |
|
|
then |
|
|
grep -vf "${adb_tmpdir}/tmp.whitelist" "${adb_tmpfile}" 2>/dev/null | eval "${adb_dnsformat}" > "${adb_dnsfile}" |
|
|
grep -vf "${adb_tmpdir}/tmp.whitelist" "${adb_tmpfile}" 2>/dev/null | eval "${adb_dnsformat}" > "${adb_dnsfile}" |
|
|
else |
|
|
else |
|
|
cat "${adb_tmpfile}" 2>/dev/null | eval "${adb_dnsformat}" > "${adb_dnsfile}" |
|
|
|
|
|
|
|
|
eval "${adb_dnsformat}" "${adb_tmpfile}" > "${adb_dnsfile}" |
|
|
fi |
|
|
fi |
|
|
adb_rc=${?} |
|
|
adb_rc=${?} |
|
|
if [ ${adb_rc} -ne 0 ] |
|
|
if [ ${adb_rc} -ne 0 ] |
|
@ -554,7 +559,7 @@ f_main() |
|
|
# handle different adblock actions |
|
|
# handle different adblock actions |
|
|
# |
|
|
# |
|
|
f_envload |
|
|
f_envload |
|
|
case "${1}" in |
|
|
|
|
|
|
|
|
case "${adb_action}" in |
|
|
stop) |
|
|
stop) |
|
|
f_rmtemp |
|
|
f_rmtemp |
|
|
f_rmdns |
|
|
f_rmdns |
|
|