From 0da873fbb9cee37c5264f1ca3f01eb6f11a657da Mon Sep 17 00:00:00 2001 From: sbwml Date: Mon, 26 Feb 2024 21:31:40 +0800 Subject: [PATCH] luci-app-mosdns: fix using local filter lists to get stuck in infinite loops Signed-off-by: sbwml --- luci-app-mosdns/Makefile | 2 +- luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua | 3 +-- luci-app-mosdns/root/etc/init.d/mosdns | 4 +++- luci-app-mosdns/root/usr/share/mosdns/mosdns.sh | 9 ++++++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/luci-app-mosdns/Makefile b/luci-app-mosdns/Makefile index 9e81e03..c08215f 100644 --- a/luci-app-mosdns/Makefile +++ b/luci-app-mosdns/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-mosdns -PKG_VERSION:=1.5.17 +PKG_VERSION:=1.5.18 PKG_RELEASE:=1 LUCI_TITLE:=LuCI Support for mosdns diff --git a/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua b/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua index e10da07..4af0903 100644 --- a/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua +++ b/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua @@ -174,8 +174,7 @@ o.default = "geosite.dat" 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/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/ookangzheng/dbl-oisd-nl/master/dbl.txt", "oisd (big)") +o:value("https://raw.githubusercontent.com/neodevpro/neodevhost/master/domain", "NEO DEV HOST") o = s:taboption("basic", Button, "_reload", translate("Restart-Service"), translate("Restart the MosDNS process to take effect of new configuration")) o.write = function() diff --git a/luci-app-mosdns/root/etc/init.d/mosdns b/luci-app-mosdns/root/etc/init.d/mosdns index f12b5a8..3d9f580 100755 --- a/luci-app-mosdns/root/etc/init.d/mosdns +++ b/luci-app-mosdns/root/etc/init.d/mosdns @@ -228,7 +228,9 @@ start_service() { if [ -f "/etc/mosdns/rule/.ad_source" ]; then for url in $ad_source; 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 update_list=1 break diff --git a/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh b/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh index eb6411b..fa9ffca 100755 --- a/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh +++ b/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh @@ -54,10 +54,17 @@ get_adlist() ( adlist_update() { [ "$(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_TMPDIR=$(mktemp -d) || exit 1 mirror="" : > /etc/mosdns/rule/.ad_source + if [ -f "$lock_file" ]; then + has_update=0 + exit 0 + else + : > $lock_file + fi has_update=0 for url in $ad_source; do @@ -83,7 +90,7 @@ adlist_update() { \cp $AD_TMPDIR/* /etc/mosdns/rule/adlist } fi - rm -rf "$AD_TMPDIR" + rm -rf "$AD_TMPDIR" $lock_file } geodat_update() (