luci-app-mosdns: fix using local filter lists to get stuck in infinite loops

Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
sbwml 2024-02-26 21:31:40 +08:00
parent 67e88512fe
commit 0da873fbb9
4 changed files with 13 additions and 5 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-mosdns PKG_NAME:=luci-app-mosdns
PKG_VERSION:=1.5.17 PKG_VERSION:=1.5.18
PKG_RELEASE:=1 PKG_RELEASE:=1
LUCI_TITLE:=LuCI Support for mosdns LUCI_TITLE:=LuCI Support for mosdns

View File

@ -174,8 +174,7 @@ o.default = "geosite.dat"
o:value("geosite.dat", "v2ray-geosite") o:value("geosite.dat", "v2ray-geosite")
o:value("https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt", "anti-AD") o:value("https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt", "anti-AD")
o:value("https://raw.githubusercontent.com/Cats-Team/AdRules/main/mosdns_adrules.txt", "Cats-Team/AdRules") o:value("https://raw.githubusercontent.com/Cats-Team/AdRules/main/mosdns_adrules.txt", "Cats-Team/AdRules")
o:value("https://raw.githubusercontent.com/ookangzheng/dbl-oisd-nl/master/dbl_light.txt", "oisd (small)") o:value("https://raw.githubusercontent.com/neodevpro/neodevhost/master/domain", "NEO DEV HOST")
o:value("https://raw.githubusercontent.com/ookangzheng/dbl-oisd-nl/master/dbl.txt", "oisd (big)")
o = s:taboption("basic", Button, "_reload", translate("Restart-Service"), translate("Restart the MosDNS process to take effect of new configuration")) o = s:taboption("basic", Button, "_reload", translate("Restart-Service"), translate("Restart the MosDNS process to take effect of new configuration"))
o.write = function() o.write = function()

View File

@ -228,7 +228,9 @@ start_service() {
if [ -f "/etc/mosdns/rule/.ad_source" ]; then if [ -f "/etc/mosdns/rule/.ad_source" ]; then
for url in $ad_source; for url in $ad_source;
do do
[ "$url" = "geosite.dat" ] && continue if [ "$url" = "geosite.dat" ] || [ $(echo "$url" | grep -c -E "^file://") -eq 1 ]; then
continue
fi
if [ $(grep -c "$url" "/etc/mosdns/rule/.ad_source") -eq 0 ]; then if [ $(grep -c "$url" "/etc/mosdns/rule/.ad_source") -eq 0 ]; then
update_list=1 update_list=1
break break

View File

@ -54,10 +54,17 @@ get_adlist() (
adlist_update() { adlist_update() {
[ "$(uci -q get mosdns.config.adblock)" != 1 ] && exit 0 [ "$(uci -q get mosdns.config.adblock)" != 1 ] && exit 0
lock_file=/var/lock/mosdns_ad_update.lock
ad_source=$(uci -q get mosdns.config.ad_source) ad_source=$(uci -q get mosdns.config.ad_source)
AD_TMPDIR=$(mktemp -d) || exit 1 AD_TMPDIR=$(mktemp -d) || exit 1
mirror="" mirror=""
: > /etc/mosdns/rule/.ad_source : > /etc/mosdns/rule/.ad_source
if [ -f "$lock_file" ]; then
has_update=0
exit 0
else
: > $lock_file
fi
has_update=0 has_update=0
for url in $ad_source; for url in $ad_source;
do do
@ -83,7 +90,7 @@ adlist_update() {
\cp $AD_TMPDIR/* /etc/mosdns/rule/adlist \cp $AD_TMPDIR/* /etc/mosdns/rule/adlist
} }
fi fi
rm -rf "$AD_TMPDIR" rm -rf "$AD_TMPDIR" $lock_file
} }
geodat_update() ( geodat_update() (