Browse Source

Merge pull request #3690 from dibdot/adblock

adblock: bugfix 2.0.1
lilik-openwrt-22.03
Hannu Nyman 8 years ago
committed by GitHub
parent
commit
b81e0b2839
3 changed files with 20 additions and 19 deletions
  1. +1
    -1
      net/adblock/Makefile
  2. +1
    -1
      net/adblock/files/adblock.init
  3. +18
    -17
      net/adblock/files/adblock.sh

+ 1
- 1
net/adblock/Makefile View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=adblock
PKG_VERSION:=2.0.0
PKG_VERSION:=2.0.1
PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0+
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>


+ 1
- 1
net/adblock/files/adblock.init View File

@ -8,6 +8,7 @@ EXTRA_COMMANDS="suspend resume"
EXTRA_HELP=" suspend Suspend adblock processing
resume Resume adblock processing"
exec 2>/dev/null
adb_script="/usr/bin/adblock.sh"
adb_iface="$(uci -q get adblock.global.adb_iface)"
@ -69,7 +70,6 @@ service_triggers()
local iface
procd_add_config_trigger "config.change" "adblock" /etc/init.d/adblock start
if [ -z "${adb_iface}" ]
then
procd_add_raw_trigger "interface.*.up" 1000 /etc/init.d/adblock start


+ 18
- 17
net/adblock/files/adblock.sh View File

@ -10,7 +10,7 @@
#
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
adb_ver="2.0.0"
adb_ver="2.0.1"
adb_enabled=1
adb_debug=0
adb_whitelist="/etc/adblock/adblock.whitelist"
@ -88,6 +88,11 @@ f_envcheck()
#
if [ "${adb_enabled}" != "1" ]
then
if [ "$(ls -dA "${adb_dnsdir}/${adb_dnsprefix}"* >/dev/null 2>&1)" ]
then
f_rmdns
f_dnsrestart
fi
f_log "info " "status ::: adblock is currently disabled, please set adb_enabled to '1' to use this service"
exit 0
fi
@ -153,18 +158,21 @@ f_dnsrestart()
dns_running="false"
sync
"/etc/init.d/${adb_dns}" restart
killall -q -TERM "${adb_dns}"
while [ ${cnt} -le 10 ]
do
dns_running="$(ubus -S call service list '{"name":"dnsmasq"}' | jsonfilter -e '@.dnsmasq.instances.*.running')"
if [ "${dns_running}" = "true" ]
then
sleep 1
break
fi
cnt=$((cnt+1))
sleep 1
done
if [ "${dns_running}" = "false" ]
then
/etc/init.d/"${adb_dns}" restart
fi
}
# f_list: backup/restore/remove block lists
@ -369,29 +377,22 @@ f_main()
f_log "debug" "loop ::: name: ${src_name}, list-rc: ${rc}"
done
# overall sort, make block list entries unique
# make overall sort, restart & check dns server
#
for list in $(ls -ASr "${adb_dnsdir}/${adb_dnsprefix}"* 2>/dev/null)
for src_name in $(ls -dASr "${adb_dnsdir}/${adb_dnsprefix}"* 2>/dev/null)
do
list="${list/*./}"
if [ -s "${adb_tmpdir}/blocklist.overall" ]
then
sort "${adb_tmpdir}/blocklist.overall" "${adb_tmpdir}/blocklist.overall" "${adb_dnsdir}/${adb_dnsprefix}.${list}" | uniq -u > "${adb_tmpdir}/tmp.blocklist"
cat "${adb_tmpdir}/tmp.blocklist" > "${adb_dnsdir}/${adb_dnsprefix}.${list}"
sort "${adb_tmpdir}/blocklist.overall" "${adb_tmpdir}/blocklist.overall" "${src_name}" | uniq -u > "${adb_tmpdir}/tmp.blocklist"
cat "${adb_tmpdir}/tmp.blocklist" > "${src_name}"
fi
cat "${adb_dnsdir}/${adb_dnsprefix}.${list}" >> "${adb_tmpdir}/blocklist.overall"
cat "${src_name}" >> "${adb_tmpdir}/blocklist.overall"
cnt="$(wc -l < "${src_name}")"
sum_cnt=$((sum_cnt + cnt))
done
# restart & check dns server
#
f_dnsrestart
if [ "${dns_running}" = "true" ]
then
for src_name in $(ls -ASr "${adb_dnsdir}/${adb_dnsprefix}"* 2>/dev/null)
do
cnt="$(wc -l < "${src_name}")"
sum_cnt=$((sum_cnt + cnt))
done
f_debug
f_rmtemp
f_log "info " "status ::: block lists with overall ${sum_cnt} domains loaded (${adb_sysver})"


Loading…
Cancel
Save