luci-app-mosdns: add local AD rules file support

This commit is contained in:
sbwml 2023-09-21 18:05:42 +08:00
parent fb013521e7
commit ccfebc96f4
4 changed files with 8 additions and 3 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.9 PKG_VERSION:=1.5.10
PKG_RELEASE:=1 PKG_RELEASE:=1
LUCI_TITLE:=LuCI Support for mosdns LUCI_TITLE:=LuCI Support for mosdns

View File

@ -169,7 +169,7 @@ o = s:taboption("advanced", Flag, "adblock", translate("Enable DNS ADblock"))
o:depends("configfile", "/etc/mosdns/config.yaml") o:depends("configfile", "/etc/mosdns/config.yaml")
o.default = false o.default = false
o = s:taboption("advanced", DynamicList, "ad_source", translate("ADblock Source"), translate("When using custom rule sources, please use rule types supported by MosDNS (domain lists).")) o = s:taboption("advanced", DynamicList, "ad_source", translate("ADblock Source"), translate("When using custom rule sources, please use rule types supported by MosDNS (domain lists).") .. '<br />' .. translate("Support for local files, such as: file:///var/mosdns/example.txt"))
o:depends("adblock", "1") o:depends("adblock", "1")
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")

View File

@ -76,6 +76,9 @@ msgstr "广告过滤规则来源"
msgid "When using custom rule sources, please use rule types supported by MosDNS (domain lists)." msgid "When using custom rule sources, please use rule types supported by MosDNS (domain lists)."
msgstr "使用自定义规则来源时,请使用 MosDNS 支持的规则类型(域名列表)" msgstr "使用自定义规则来源时,请使用 MosDNS 支持的规则类型(域名列表)"
msgid "Support for local files, such as: file:///var/mosdns/example.txt"
msgstr "支持本地文件例如file:///var/mosdns/example.txt"
msgid "Restart-Service" msgid "Restart-Service"
msgstr "重启服务" msgstr "重启服务"

View File

@ -38,6 +38,8 @@ get_adlist() (
do do
if [ $(echo $url) = 'geosite.dat' ]; then if [ $(echo $url) = 'geosite.dat' ]; then
echo " - \"/var/mosdns/geosite_category-ads-all.txt\"" echo " - \"/var/mosdns/geosite_category-ads-all.txt\""
elif echo "$url" | grep -Eq "^file://" ; then
echo " - \"$(echo "$url" | sed 's/file:\/\///')\""
else else
echo " - \"/etc/mosdns/rule/adlist/$(basename $url)\"" echo " - \"/etc/mosdns/rule/adlist/$(basename $url)\""
[ ! -f "/etc/mosdns/rule/adlist/$(basename $url)" ] && touch /etc/mosdns/rule/adlist/$(basename $url) [ ! -f "/etc/mosdns/rule/adlist/$(basename $url)" ] && touch /etc/mosdns/rule/adlist/$(basename $url)
@ -60,7 +62,7 @@ adlist_update() (
has_update=0 has_update=0
for url in $ad_source; for url in $ad_source;
do do
if [ "$url" != "geosite.dat" ]; then if [ "$url" != "geosite.dat" ] && [ $(echo "$url" | grep -c -E "^file://") -eq 0 ]; then
echo "$url" >> /etc/mosdns/rule/.ad_source echo "$url" >> /etc/mosdns/rule/.ad_source
filename=$(basename $url) filename=$(basename $url)
if echo "$url" | grep -Eq "^https://raw.githubusercontent.com" ; then if echo "$url" | grep -Eq "^https://raw.githubusercontent.com" ; then