Use geosite.dat:category-ads-all AD List

This commit is contained in:
sbwml 2022-04-08 08:14:38 +08:00
parent 6d2a207cb0
commit 73a309951c
11 changed files with 35 additions and 61167 deletions

View File

@ -10,7 +10,8 @@ function index()
page.acl_depends = { "luci-app-mosdns" }
entry({"admin", "services", "mosdns", "basic"}, cbi("mosdns/basic"), _("Basic Setting"), 1).leaf = true
entry({"admin", "services", "mosdns", "update"}, cbi("mosdns/update"), _("Geodata Update"), 2).leaf = true
entry({"admin", "services", "mosdns", "whitelist"}, cbi("mosdns/whitelist"), _("ADblock whitelist"), 2).leaf = true
entry({"admin", "services", "mosdns", "update"}, cbi("mosdns/update"), _("Geodata Update"), 3).leaf = true
entry({"admin", "services", "mosdns", "status"}, call("act_status")).leaf = true
end

View File

@ -78,19 +78,4 @@ function config.write(self, section, value)
nixio.fs.writefile("/etc/mosdns/cus_config.yaml", value)
end
config = s:option(TextValue, "whitelist")
config.description = translate("<font color=\"ff0000\"><strong>ADblock whitelist.")
config.template = "cbi/tvalue"
config.rows = 25
config:depends( "configfile", "./def_config.yaml")
function config.cfgvalue(self, section)
return nixio.fs.readfile("/etc/mosdns/whitelist.txt")
end
function config.write(self, section, value)
value = value:gsub("\r\n?", "\n")
nixio.fs.writefile("/etc/mosdns/whitelist.txt", value)
end
return m

View File

@ -2,8 +2,6 @@ m = Map("mosdns")
m.title = translate("MosDNS")
m.description = translate("MosDNS is a 'programmable' DNS forwarder.")
m:section(SimpleSection).template = "mosdns/mosdns_status"
s = m:section(TypedSection, "mosdns")
s.addremove = false
s.anonymous = true
@ -11,9 +9,6 @@ s.anonymous = true
enable = s:option(Flag, "geo_auto_update", translate("Enable Auto Database Update"))
enable.rmempty = false
enable = s:option(Flag, "update_adlist", translate("Enable ADList Update"))
enable.rmempty = false
o = s:option(ListValue, "geo_update_week_time", translate("Update Cycle"))
o:value("*", translate("Every Day"))
o:value("1", translate("Every Monday"))

View File

@ -0,0 +1,23 @@
m = Map("mosdns")
m.title = translate("MosDNS")
m.description = translate("MosDNS is a 'programmable' DNS forwarder.")
s = m:section(TypedSection, "mosdns")
s.addremove = false
s.anonymous = true
config = s:option(TextValue, "whitelist")
config.description = translate("<font color=\"ff0000\"><strong>ADblock whitelist.")
config.template = "cbi/tvalue"
config.rows = 25
function config.cfgvalue(self, section)
return nixio.fs.readfile("/etc/mosdns/whitelist.txt")
end
function config.write(self, section, value)
value = value:gsub("\r\n?", "\n")
nixio.fs.writefile("/etc/mosdns/whitelist.txt", value)
end
return m

View File

@ -31,6 +31,9 @@ msgstr "<font color=\"ff0000\"><strong>注意!此页的更改仅当 'MosDNS
msgid "<font color=\"ff0000\"><strong>ADblock whitelist."
msgstr "<font color=\"ff0000\"><strong>广告过滤白名单"
msgid "ADblock whitelist"
msgstr "白名单"
msgid "Geodata Update"
msgstr "数据库更新"
@ -73,9 +76,6 @@ msgstr "检查并更新"
msgid "Enable Auto Database Update"
msgstr "启用数据库自动更新"
msgid "Enable ADList Update"
msgstr "更新广告过滤列表"
msgid "Enable AutoConfiguration"
msgstr "启用自动化配置"

View File

@ -62,16 +62,6 @@ delcron() {
crontab $CRON_FILE
}
adblock() {
cp -f /etc/mosdns/serverlist.txt /etc/mosdns/serverlist.bak
modns_adblock=$(uci -q get mosdns.mosdns.adblock)
if [ "$modns_adblock" = 0 ]; then
: > /etc/mosdns/serverlist.txt
else
cat /etc/mosdns/serverlist.bak >/etc/mosdns/serverlist.txt
fi
}
start_service() {
# Reading config
@ -87,7 +77,6 @@ start_service() {
fi
delcron
setcron
adblock
procd_open_instance mosdns
procd_set_param command $PROG -dir $RES_DIR -c "$CONF"
procd_set_param user root

6
root/etc/mosdns/ad_domain.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash -e
adblock=$(uci -q get mosdns.mosdns.adblock)
if [ "$adblock" -eq 1 ];then
echo "ext:/usr/share/v2ray/geosite.dat:category-ads-all"
fi

View File

@ -99,7 +99,7 @@ plugin:
type: query_matcher
args:
domain:
- "ext:./serverlist.txt"
- ${{ ./ad_domain.sh }}
- tag: qtype65
type: query_matcher

View File

@ -19,14 +19,6 @@ getdat() {
fi
}
get_adlist() {
if exist curl; then
curl -fSLo "$TMPDIR/$1" "https://raw.cooluc.com/QiuSimons/openwrt-mos/master/dat/$1"
else
wget "https://raw.cooluc.com/QiuSimons/openwrt-mos/master/dat/$1" -nv -O "$TMPDIR/$1"
fi
}
getdns() {
if [ "$2" == "inactive" ]; then
ubus call network.interface.wan status | jsonfilter -e "@['inactive']['dns-server'][$1]"

View File

@ -16,14 +16,4 @@ fi
cp -rf "$TMPDIR"/* /usr/share/v2ray
rm -rf "$TMPDIR"
update_adlist=$(uci -q get mosdns.mosdns.update_adlist)
if [ "$update_adlist" -eq 1 ]; then
TMPDIR=$(mktemp -d) || exit 2
get_adlist serverlist.txt
if [ "$(grep -o .com "$TMPDIR"/serverlist.txt | wc -l)" -lt "1000" ]; then
rm -rf "$TMPDIR"/serverlist.txt
fi
cp -rf "$TMPDIR"/* /etc/mosdns
rm -rf /etc/mosdns/serverlist.bak
fi
exit 0

File diff suppressed because it is too large Load Diff