update 04-08 19:32
This commit is contained in:
parent
45a055f9e4
commit
075d322100
|
@ -1,9 +1,9 @@
|
||||||
module("luci.controller.fileassistant", package.seeall)
|
module("luci.controller.fileassistant", package.seeall)
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
entry({"admin", "system"}, firstchild(), _("FileAssistant") , 45).dependent = false
|
entry({"admin", "system"}, firstchild(), _("System") , 45).dependent = false
|
||||||
|
|
||||||
entry({"admin", "system"}, firstchild(), "FileAssistant", 44).dependent = false
|
entry({"admin", "system"}, firstchild(), "System", 44).dependent = false
|
||||||
|
|
||||||
local page
|
local page
|
||||||
page = entry({"admin", "system", "fileassistant"}, template("fileassistant"), _("文件助手"), 1)
|
page = entry({"admin", "system", "fileassistant"}, template("fileassistant"), _("文件助手"), 1)
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=luci-app-mosdns
|
||||||
|
PKG_VERSION:=1.2
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
LUCI_TITLE:=LuCI Support for mosdns
|
||||||
|
LUCI_PKGARCH:=all
|
||||||
|
LUCI_DEPENDS:=+mosdns +jsonfilter +bash +v2ray-geoip +v2ray-geosite
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/conffiles
|
||||||
|
/etc/mosdns/cus_config.yaml
|
||||||
|
/etc/config/mosdns
|
||||||
|
endef
|
||||||
|
|
||||||
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
||||||
|
# call BuildPackage - OpenWrt buildroot signature
|
|
@ -0,0 +1,22 @@
|
||||||
|
module("luci.controller.mosdns", package.seeall)
|
||||||
|
|
||||||
|
function index()
|
||||||
|
if not nixio.fs.access("/etc/config/mosdns") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local page = entry({"admin", "services", "mosdns"}, alias("admin", "services", "mosdns", "basic"), _("MosDNS"), 30)
|
||||||
|
page.dependent = true
|
||||||
|
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", "status"}, call("act_status")).leaf = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function act_status()
|
||||||
|
local e = {}
|
||||||
|
e.running = luci.sys.call("pgrep -f mosdns >/dev/null") == 0
|
||||||
|
luci.http.prepare_content("application/json")
|
||||||
|
luci.http.write_json(e)
|
||||||
|
end
|
|
@ -0,0 +1,87 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
enable = s:option(Flag, "enabled", translate("Enable"))
|
||||||
|
enable.rmempty = false
|
||||||
|
|
||||||
|
configfile = s:option(ListValue, "configfile", translate("MosDNS Config File"))
|
||||||
|
configfile:value("./def_config.yaml", translate("Def Config"))
|
||||||
|
configfile:value("./cus_config.yaml", translate("Cus Config"))
|
||||||
|
configfile.default = "./def_config.yaml"
|
||||||
|
|
||||||
|
loglv = s:option(ListValue, "loglv", translate("Log Level"))
|
||||||
|
loglv:value("debug")
|
||||||
|
loglv:value("info")
|
||||||
|
loglv:value("warn")
|
||||||
|
loglv:value("error")
|
||||||
|
loglv.default = "error"
|
||||||
|
loglv:depends( "configfile", "./def_config.yaml")
|
||||||
|
|
||||||
|
logfile = s:option(Value, "logfile", translate("MosDNS Log File"))
|
||||||
|
logfile.placeholder = "/dev/null"
|
||||||
|
logfile.default = "/dev/null"
|
||||||
|
logfile:depends( "configfile", "./def_config.yaml")
|
||||||
|
|
||||||
|
redirect = s:option(Flag, "redirect", translate("Enable DNS Redirect"))
|
||||||
|
redirect:depends( "configfile", "./def_config.yaml")
|
||||||
|
redirect.default = true
|
||||||
|
|
||||||
|
adblock = s:option(Flag, "adblock", translate("Enable DNS ADblock"))
|
||||||
|
adblock:depends( "configfile", "./def_config.yaml")
|
||||||
|
adblock.default = true
|
||||||
|
|
||||||
|
set_config = s:option(Button, "set_config", translate("DNS Helper"))
|
||||||
|
set_config.inputtitle = translate("Apply")
|
||||||
|
set_config.inputstyle = "reload"
|
||||||
|
set_config.description = translate("This will make the necessary adjustments to other plug-in settings.")
|
||||||
|
set_config.write = function()
|
||||||
|
luci.sys.exec("/etc/mosdns/set.sh &> /dev/null &")
|
||||||
|
end
|
||||||
|
set_config:depends( "configfile", "./def_config.yaml")
|
||||||
|
|
||||||
|
unset_config = s:option(Button, "unset_config", translate("Revert Settings"))
|
||||||
|
unset_config.inputtitle = translate("Apply")
|
||||||
|
unset_config.inputstyle = "reload"
|
||||||
|
unset_config.description = translate("This will revert the adjustments.")
|
||||||
|
unset_config.write = function()
|
||||||
|
luci.sys.exec("/etc/mosdns/set.sh unset &> /dev/null &")
|
||||||
|
end
|
||||||
|
|
||||||
|
config = s:option(TextValue, "manual-config")
|
||||||
|
config.description = translate("<font color=\"ff0000\"><strong>View the Custom YAML Configuration file used by this MosDNS. You can edit it as you own need.")
|
||||||
|
config.template = "cbi/tvalue"
|
||||||
|
config.rows = 25
|
||||||
|
config:depends( "configfile", "./cus_config.yaml")
|
||||||
|
|
||||||
|
function config.cfgvalue(self, section)
|
||||||
|
return nixio.fs.readfile("/etc/mosdns/cus_config.yaml")
|
||||||
|
end
|
||||||
|
|
||||||
|
function config.write(self, section, value)
|
||||||
|
value = value:gsub("\r\n?", "\n")
|
||||||
|
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
|
|
@ -0,0 +1,41 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
enable = s:option(Flag, "geo_auto_update", translate("Enable Auto Database Update"))
|
||||||
|
enable.rmempty = false
|
||||||
|
|
||||||
|
enable = s:option(Flag, "syncconfig", translate("Enable Config 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"))
|
||||||
|
o:value("2", translate("Every Tuesday"))
|
||||||
|
o:value("3", translate("Every Wednesday"))
|
||||||
|
o:value("4", translate("Every Thursday"))
|
||||||
|
o:value("5", translate("Every Friday"))
|
||||||
|
o:value("6", translate("Every Saturday"))
|
||||||
|
o:value("7", translate("Every Sunday"))
|
||||||
|
o.default = "*"
|
||||||
|
|
||||||
|
update_time = s:option(ListValue, "geo_update_day_time", translate("Update Time (Every Day)"))
|
||||||
|
for t = 0, 23 do
|
||||||
|
update_time:value(t, t..":00")
|
||||||
|
end
|
||||||
|
update_time.default = 0
|
||||||
|
|
||||||
|
data_update = s:option(Button, "geo_update_database", translate("Database Update"))
|
||||||
|
data_update.inputtitle = translate("Check And Update")
|
||||||
|
data_update.inputstyle = "reload"
|
||||||
|
data_update.write = function()
|
||||||
|
luci.sys.exec("/etc/mosdns/mosupdater.sh &> /dev/null &")
|
||||||
|
end
|
||||||
|
|
||||||
|
return m
|
|
@ -0,0 +1,28 @@
|
||||||
|
<script type="text/javascript">
|
||||||
|
//<![CDATA[
|
||||||
|
XHR.poll(3, '<%=url([[admin]], [[services]], [[mosdns]], [[status]])%>', null,
|
||||||
|
function(x, data) {
|
||||||
|
var tb = document.getElementById('mosdns_status');
|
||||||
|
if (data && tb) {
|
||||||
|
if (data.running) {
|
||||||
|
var links = '<em><b style=color:green>MosDNS <%:RUNNING%></b></em>';
|
||||||
|
tb.innerHTML = links;
|
||||||
|
} else {
|
||||||
|
tb.innerHTML = '<em><b style=color:red>MosDNS <%:NOT RUNNING%></b></em>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.mar-10 {
|
||||||
|
margin-left: 50px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<fieldset class="cbi-section">
|
||||||
|
<p id="mosdns_status">
|
||||||
|
<em><%:Collecting data...%></em>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
|
@ -0,0 +1,107 @@
|
||||||
|
msgid "Basic Setting"
|
||||||
|
msgstr "基本设置"
|
||||||
|
|
||||||
|
msgid "Manual Configuration"
|
||||||
|
msgstr "手动配置"
|
||||||
|
|
||||||
|
msgid "MosDNS is a 'programmable' DNS forwarder."
|
||||||
|
msgstr "MosDNS 是一个插件化的 DNS 转发/分流器。"
|
||||||
|
|
||||||
|
msgid "RUNNING"
|
||||||
|
msgstr "运行中"
|
||||||
|
|
||||||
|
msgid "NOT RUNNING"
|
||||||
|
msgstr "未运行"
|
||||||
|
|
||||||
|
msgid "Collecting data..."
|
||||||
|
msgstr "获取数据中..."
|
||||||
|
|
||||||
|
msgid "Enable"
|
||||||
|
msgstr "启用"
|
||||||
|
|
||||||
|
msgid "Enable DNS Redirect"
|
||||||
|
msgstr "启用 DNS 重定向"
|
||||||
|
|
||||||
|
msgid "Enable DNS ADblock"
|
||||||
|
msgstr "启用 DNS 广告过滤"
|
||||||
|
|
||||||
|
msgid "<font color=\"ff0000\"><strong>View the Custom YAML Configuration file used by this MosDNS. You can edit it as you own need."
|
||||||
|
msgstr "<font color=\"ff0000\"><strong>注意!此页的更改仅当 'MosDNS 配置文件选择' 为 '自定义配置' 时才会生效"
|
||||||
|
|
||||||
|
msgid "<font color=\"ff0000\"><strong>ADblock whitelist."
|
||||||
|
msgstr "<font color=\"ff0000\"><strong>广告过滤白名单"
|
||||||
|
|
||||||
|
msgid "Geodata Update"
|
||||||
|
msgstr "数据库更新"
|
||||||
|
|
||||||
|
msgid "Update Time (Every Day)"
|
||||||
|
msgstr "更新时间(每天)"
|
||||||
|
|
||||||
|
msgid "Update Cycle"
|
||||||
|
msgstr "更新周期"
|
||||||
|
|
||||||
|
msgid "Every Day"
|
||||||
|
msgstr "每天"
|
||||||
|
|
||||||
|
msgid "Every Monday"
|
||||||
|
msgstr "每周一"
|
||||||
|
|
||||||
|
msgid "Every Tuesday"
|
||||||
|
msgstr "每周二"
|
||||||
|
|
||||||
|
msgid "Every Wednesday"
|
||||||
|
msgstr "每周三"
|
||||||
|
|
||||||
|
msgid "Every Thursday"
|
||||||
|
msgstr "每周四"
|
||||||
|
|
||||||
|
msgid "Every Friday"
|
||||||
|
msgstr "每周五"
|
||||||
|
|
||||||
|
msgid "Every Saturday"
|
||||||
|
msgstr "每周六"
|
||||||
|
|
||||||
|
msgid "Every Sunday"
|
||||||
|
msgstr "每周日"
|
||||||
|
|
||||||
|
msgid "Database Update"
|
||||||
|
msgstr "数据库更新"
|
||||||
|
|
||||||
|
msgid "Check And Update"
|
||||||
|
msgstr "检查并更新"
|
||||||
|
|
||||||
|
msgid "Enable Auto Database Update"
|
||||||
|
msgstr "启用数据库自动更新"
|
||||||
|
|
||||||
|
msgid "Enable Config Update"
|
||||||
|
msgstr "启用配置文件同步"
|
||||||
|
|
||||||
|
msgid "Enable AutoConfiguration"
|
||||||
|
msgstr "启用自动化配置"
|
||||||
|
|
||||||
|
msgid "This will make the necessary adjustments to other plug-in settings."
|
||||||
|
msgstr "对其他插件的设置进行必要的设置,目前仅支持 SSRP VSSR PASSWALL。"
|
||||||
|
|
||||||
|
msgid "This will revert the adjustments."
|
||||||
|
msgstr "还原设置助手对其他插件进行的配置设定。"
|
||||||
|
|
||||||
|
msgid "DNS Helper"
|
||||||
|
msgstr "DNS 设置助手"
|
||||||
|
|
||||||
|
msgid "Revert Settings"
|
||||||
|
msgstr "DNS 设置还原"
|
||||||
|
|
||||||
|
msgid "Apply"
|
||||||
|
msgstr "应用"
|
||||||
|
|
||||||
|
msgid "MosDNS Config File"
|
||||||
|
msgstr "MosDNS 配置文件选择"
|
||||||
|
|
||||||
|
msgid "Def Config"
|
||||||
|
msgstr "内置预设"
|
||||||
|
|
||||||
|
msgid "Cus Config"
|
||||||
|
msgstr "自定义配置"
|
||||||
|
|
||||||
|
msgid "MosDNS Log File"
|
||||||
|
msgstr "MosDNS 日志文件"
|
|
@ -0,0 +1 @@
|
||||||
|
zh-cn
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
config mosdns 'mosdns'
|
||||||
|
option not_first_start '0'
|
||||||
|
option enabled '0'
|
||||||
|
option geo_auto_update '0'
|
||||||
|
option geo_update_week_time 'all'
|
||||||
|
option geo_update_day_time '2'
|
||||||
|
option redirect '1'
|
||||||
|
option autoconf '1'
|
||||||
|
option syncconfig '1'
|
||||||
|
option adblock '0'
|
||||||
|
option configfile './def_config.yaml'
|
||||||
|
option loglv 'error'
|
||||||
|
option logfile '/dev/null'
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
[ "$ACTION" = ifup ] && /etc/init.d/mosdns restart
|
|
@ -0,0 +1,137 @@
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
# Copyright (C) 2020 IrineSistiana
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
|
START=91
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
##### ONLY CHANGE THIS BLOCK ######
|
||||||
|
PROG=/usr/bin/mosdns # where is mosdns
|
||||||
|
RES_DIR=/etc/mosdns/ # resource dir / working dir / the dir where you store ip/domain lists
|
||||||
|
CONF=$(uci -q get mosdns.mosdns.configfile) # where is the config file, it can be a relative path to $RES_DIR
|
||||||
|
CRON_FILE=/etc/crontabs/root
|
||||||
|
##### ONLY CHANGE THIS BLOCK ######
|
||||||
|
|
||||||
|
inital_conf() {
|
||||||
|
config_load "mosdns"
|
||||||
|
config_get "enabled" "mosdns" "enabled" "0"
|
||||||
|
}
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "mosdns"
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_setting() {
|
||||||
|
sed -i "/list server/d" /etc/config/dhcp
|
||||||
|
uci set dhcp.@dnsmasq[0].noresolv='0'
|
||||||
|
uci del dhcp.@dnsmasq[0].cachesize
|
||||||
|
uci set dhcp.@dnsmasq[0].filter_aaaa='1'
|
||||||
|
uci commit dhcp
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_setting() {
|
||||||
|
redirect=$(uci -q get mosdns.mosdns.redirect)
|
||||||
|
if [ "$redirect" -eq 1 ]; then
|
||||||
|
sed -i "/list server/d" /etc/config/dhcp
|
||||||
|
uci add_list dhcp.@dnsmasq[0].server='127.0.0.1#5335'
|
||||||
|
uci set dhcp.@dnsmasq[0].rebind_protection='0'
|
||||||
|
uci set dhcp.@dnsmasq[0].noresolv="1"
|
||||||
|
uci set dhcp.@dnsmasq[0].cachesize='0'
|
||||||
|
uci set dhcp.@dnsmasq[0].filter_aaaa='0'
|
||||||
|
uci commit dhcp
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
restart_others() {
|
||||||
|
/etc/init.d/network reload
|
||||||
|
/etc/init.d/dnsmasq reload
|
||||||
|
}
|
||||||
|
|
||||||
|
reload_service() {
|
||||||
|
stop
|
||||||
|
sleep 2s
|
||||||
|
echo "MosDNS is restarted!"
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
setcron() {
|
||||||
|
touch $CRON_FILE
|
||||||
|
sed -i '/mosupdater.sh/d' $CRON_FILE 2>/dev/null && {
|
||||||
|
[ "$(uci -q get mosdns.mosdns.geo_auto_update)" -eq 1 ] && echo "0 $(uci -q get mosdns.mosdns.geo_update_day_time) * * $(uci -q get mosdns.mosdns.geo_update_week_time) /etc/mosdns/mosupdater.sh" >>$CRON_FILE
|
||||||
|
}
|
||||||
|
crontab $CRON_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
delcron() {
|
||||||
|
sed -i '/mosupdater.sh/d' $CRON_FILE 2>/dev/null
|
||||||
|
/etc/init.d/cron restart
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
inital_conf
|
||||||
|
if [ "$enabled" -eq 0 ]; then
|
||||||
|
firstblood=$(uci -q get mosdns.mosdns.not_first_start)
|
||||||
|
[ "${firstblood}" = "0" ] && restore_setting
|
||||||
|
[ "${firstblood}" = "0" ] && restart_others
|
||||||
|
uci set mosdns.mosdns.not_first_start='1'
|
||||||
|
uci commit mosdns
|
||||||
|
echo "MosDNS has turned off"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
delcron
|
||||||
|
setcron
|
||||||
|
adblock
|
||||||
|
procd_open_instance mosdns
|
||||||
|
procd_set_param command $PROG -dir $RES_DIR -c "$CONF"
|
||||||
|
procd_set_param user root
|
||||||
|
procd_set_param stdout 1
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
|
||||||
|
procd_close_instance mosdns
|
||||||
|
|
||||||
|
configfile=$(uci -q get mosdns.mosdns.configfile)
|
||||||
|
if [ "${configfile}" = "./def_config.yaml" ]; then
|
||||||
|
restore_setting
|
||||||
|
prepare_setting
|
||||||
|
if [ "$(uci -q get mosdns.mosdns.redirect)" -eq 1 ] && [ "$(uci -q get shadowsocksr.@global[0].run_mode)" != gfw ]; then
|
||||||
|
cat /dev/null > /etc/ssrplus/gfw_list.conf
|
||||||
|
sed -i '/update.lua/d' /usr/share/shadowsocksr/ssrplusupdate.sh
|
||||||
|
sed -i '/bin\/sh/a\/usr/bin/lua /usr/share/shadowsocksr/update.lua ad_data' /usr/share/shadowsocksr/ssrplusupdate.sh
|
||||||
|
sed -i '/bin\/sh/a\/usr/bin/lua /usr/share/shadowsocksr/update.lua nfip_data' /usr/share/shadowsocksr/ssrplusupdate.sh
|
||||||
|
sed -i '/bin\/sh/a\/usr/bin/lua /usr/share/shadowsocksr/update.lua ip_data' /usr/share/shadowsocksr/ssrplusupdate.sh
|
||||||
|
fi
|
||||||
|
restart_others
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "MosDNS turn on"
|
||||||
|
echo "enabled=$enabled"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_service() {
|
||||||
|
|
||||||
|
pgrep -f /usr/bin/mosdns | xargs kill -9
|
||||||
|
echo "MosDNS turn off"
|
||||||
|
echo "enabled=$enabled"
|
||||||
|
|
||||||
|
configfile=$(uci -q get mosdns.mosdns.configfile)
|
||||||
|
if [ "${configfile}" = "./def_config.yaml" ]; then
|
||||||
|
config_load "mosdns"
|
||||||
|
enabled=$(uci -q get mosdns.mosdns.enabled)
|
||||||
|
[ "${enabled}" = "0" ] && restore_setting
|
||||||
|
restart_others
|
||||||
|
fi
|
||||||
|
delcron
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
log:
|
||||||
|
level: error
|
||||||
|
file: ""
|
||||||
|
|
||||||
|
plugin:
|
||||||
|
- tag: main_server
|
||||||
|
type: server
|
||||||
|
args:
|
||||||
|
entry:
|
||||||
|
- _no_ecs
|
||||||
|
- lazy_cache
|
||||||
|
- _prefer_ipv4
|
||||||
|
- _single_flight
|
||||||
|
- main_sequence
|
||||||
|
server:
|
||||||
|
- protocol: udp
|
||||||
|
addr: "127.0.0.1:5335"
|
||||||
|
- protocol: tcp
|
||||||
|
addr: "127.0.0.1:5335"
|
||||||
|
|
||||||
|
- tag: main_sequence
|
||||||
|
type: sequence
|
||||||
|
args:
|
||||||
|
exec:
|
||||||
|
- if:
|
||||||
|
- query_is_ad_domain
|
||||||
|
exec:
|
||||||
|
- _block_with_nxdomain
|
||||||
|
- _return
|
||||||
|
- if:
|
||||||
|
- query_is_local_domain
|
||||||
|
- "!_query_is_common"
|
||||||
|
exec:
|
||||||
|
- forward_local
|
||||||
|
- _return
|
||||||
|
- if:
|
||||||
|
- query_is_non_local_domain
|
||||||
|
exec:
|
||||||
|
- forward_remote
|
||||||
|
- _return
|
||||||
|
- primary:
|
||||||
|
- forward_local
|
||||||
|
- if:
|
||||||
|
- "!response_has_local_ip"
|
||||||
|
exec:
|
||||||
|
- _drop_response
|
||||||
|
secondary:
|
||||||
|
- forward_remote
|
||||||
|
fast_fallback: 150
|
||||||
|
always_standby: true
|
||||||
|
|
||||||
|
- tag: forward_local
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: ${{ ./dns.sh 0 }}
|
||||||
|
- addr: ${{ ./dns.sh 1 }}
|
||||||
|
|
||||||
|
- tag: forward_remote
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: "tls://8.8.4.4"
|
||||||
|
idle_timeout: 10
|
||||||
|
- addr: "tls://9.9.9.9"
|
||||||
|
idle_timeout: 10
|
||||||
|
|
||||||
|
- tag: lazy_cache
|
||||||
|
type: cache
|
||||||
|
args:
|
||||||
|
size: 512000
|
||||||
|
lazy_cache_ttl: 259200
|
||||||
|
|
||||||
|
- tag: query_is_local_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "ext:/usr/share/v2ray/geosite.dat:cn"
|
||||||
|
|
||||||
|
- tag: query_is_non_local_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "ext:/usr/share/v2ray/geosite.dat:geolocation-!cn"
|
||||||
|
|
||||||
|
- tag: response_has_local_ip
|
||||||
|
type: response_matcher
|
||||||
|
args:
|
||||||
|
ip:
|
||||||
|
- "ext:/usr/share/v2ray/geoip.dat:cn"
|
||||||
|
|
||||||
|
- tag: query_is_ad_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "ext:./serverlist.txt"
|
|
@ -0,0 +1,107 @@
|
||||||
|
log:
|
||||||
|
level: ${{ uci -q get mosdns.mosdns.loglv }}
|
||||||
|
file: ${{ uci -q get mosdns.mosdns.logfile }}
|
||||||
|
|
||||||
|
plugin:
|
||||||
|
- tag: main_server
|
||||||
|
type: server
|
||||||
|
args:
|
||||||
|
entry:
|
||||||
|
- _no_ecs
|
||||||
|
- lazy_cache
|
||||||
|
- _prefer_ipv4
|
||||||
|
- _single_flight
|
||||||
|
- main_sequence
|
||||||
|
server:
|
||||||
|
- protocol: udp
|
||||||
|
addr: ":5335"
|
||||||
|
- protocol: tcp
|
||||||
|
addr: ":5335"
|
||||||
|
|
||||||
|
- tag: main_sequence
|
||||||
|
type: sequence
|
||||||
|
args:
|
||||||
|
exec:
|
||||||
|
- if:
|
||||||
|
- query_is_ad_domain
|
||||||
|
- qtype65
|
||||||
|
exec:
|
||||||
|
- _block_with_nxdomain
|
||||||
|
- _return
|
||||||
|
- if:
|
||||||
|
- query_is_whitelist_domain
|
||||||
|
- query_is_local_domain
|
||||||
|
- "!_query_is_common"
|
||||||
|
exec:
|
||||||
|
- forward_local
|
||||||
|
- _return
|
||||||
|
- if:
|
||||||
|
- query_is_non_local_domain
|
||||||
|
exec:
|
||||||
|
- forward_remote
|
||||||
|
- _return
|
||||||
|
- primary:
|
||||||
|
- forward_local
|
||||||
|
- if:
|
||||||
|
- "!response_has_local_ip"
|
||||||
|
exec:
|
||||||
|
- _drop_response
|
||||||
|
secondary:
|
||||||
|
- forward_remote
|
||||||
|
fast_fallback: 150
|
||||||
|
always_standby: true
|
||||||
|
|
||||||
|
- tag: forward_local
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: ${{ ./dns.sh 0 }}
|
||||||
|
- addr: ${{ ./dns.sh 1 }}
|
||||||
|
|
||||||
|
- tag: query_is_whitelist_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "ext:./whitelist.txt"
|
||||||
|
|
||||||
|
- tag: forward_remote
|
||||||
|
type: fast_forward
|
||||||
|
args:
|
||||||
|
upstream:
|
||||||
|
- addr: "tls://8.8.4.4"
|
||||||
|
- addr: "tls://9.9.9.9"
|
||||||
|
|
||||||
|
- tag: lazy_cache
|
||||||
|
type: cache
|
||||||
|
args:
|
||||||
|
size: 512000
|
||||||
|
lazy_cache_ttl: 259200
|
||||||
|
|
||||||
|
- tag: query_is_local_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "ext:/usr/share/v2ray/geosite.dat:cn"
|
||||||
|
|
||||||
|
- tag: query_is_non_local_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "ext:/usr/share/v2ray/geosite.dat:geolocation-!cn"
|
||||||
|
|
||||||
|
- tag: response_has_local_ip
|
||||||
|
type: response_matcher
|
||||||
|
args:
|
||||||
|
ip:
|
||||||
|
- "ext:/usr/share/v2ray/geoip.dat:cn"
|
||||||
|
|
||||||
|
- tag: query_is_ad_domain
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
domain:
|
||||||
|
- "ext:./serverlist.txt"
|
||||||
|
|
||||||
|
- tag: qtype65
|
||||||
|
type: query_matcher
|
||||||
|
args:
|
||||||
|
qtype: [65]
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
# shellcheck source=/etc/mosdns/library.sh
|
||||||
|
source /etc/mosdns/library.sh
|
||||||
|
|
||||||
|
if [ "$(ifconfig | grep -c wan)" = 0 ]; then
|
||||||
|
bakdns "$1"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$(getdns 0)" =~ ^127\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
getdns "$1" inactive
|
||||||
|
elif [[ "$(getdns "$1")" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
getdns "$1"
|
||||||
|
else
|
||||||
|
bakdns "$1"
|
||||||
|
fi
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
bakdns() {
|
||||||
|
if [ "$1" == "0" ]; then
|
||||||
|
echo "119.29.29.29"
|
||||||
|
elif [ "$1" == "1" ]; then
|
||||||
|
echo "101.226.4.6"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
exist() {
|
||||||
|
command -v "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
getdat() {
|
||||||
|
if exist curl; then
|
||||||
|
curl -fSLo "$TMPDIR/$1" "https://gh.404delivr.workers.dev/https://github.com/QiuSimons/openwrt-mos/raw/master/dat/$1"
|
||||||
|
else
|
||||||
|
wget "https://gh.404delivr.workers.dev/https://github.com/QiuSimons/openwrt-mos/raw/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]"
|
||||||
|
else
|
||||||
|
ubus call network.interface.wan status | jsonfilter -e "@['dns-server'][$1]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
pid() {
|
||||||
|
pgrep -f "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
L_exist() {
|
||||||
|
if [ "$1" == "ssrp" ]; then
|
||||||
|
uci get shadowsocksr.@global[0].global_server &>/dev/null
|
||||||
|
elif [ "$1" == "pw" ]; then
|
||||||
|
uci get passwall.@global[0].enabled &>/dev/null
|
||||||
|
elif [ "$1" == "vssr" ]; then
|
||||||
|
uci get vssr.@global[0].global_server &>/dev/null
|
||||||
|
fi
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
# shellcheck source=/etc/mosdns/library.sh
|
||||||
|
|
||||||
|
set -o pipefail
|
||||||
|
source /etc/mosdns/library.sh
|
||||||
|
|
||||||
|
TMPDIR=$(mktemp -d) || exit 1
|
||||||
|
#wget https://cdn.jsdelivr.net/gh/QiuSimons/openwrt-mos@master/luci-app-mosdns/root/etc/mosdns/geoip.dat -nv -O /tmp/mosdns/geoip.dat
|
||||||
|
#wget https://cdn.jsdelivr.net/gh/QiuSimons/openwrt-mos@master/luci-app-mosdns/root/etc/mosdns/geosite.dat -nv -O /tmp/mosdns/geosite.dat
|
||||||
|
#wget https://cdn.jsdelivr.net/gh/QiuSimons/openwrt-mos@master/luci-app-mosdns/root/etc/mosdns/serverlist.txt -nv -O /tmp/mosdns/serverlist.txt
|
||||||
|
getdat geoip.dat
|
||||||
|
getdat geosite.dat
|
||||||
|
if [ "$(grep -o CN "$TMPDIR"/geoip.dat | wc -l)" -eq "0" ]; then
|
||||||
|
rm -rf "$TMPDIR"/geoip.dat
|
||||||
|
fi
|
||||||
|
if [ "$(grep -o .com "$TMPDIR"/geosite.dat | wc -l)" -lt "1000" ]; then
|
||||||
|
rm -rf "$TMPDIR"/geosite.dat
|
||||||
|
fi
|
||||||
|
cp -rf "$TMPDIR"/* /usr/share/v2ray
|
||||||
|
rm -rf "$TMPDIR"
|
||||||
|
|
||||||
|
syncconfig=$(uci -q get mosdns.mosdns.syncconfig)
|
||||||
|
if [ "$syncconfig" -eq 1 ]; then
|
||||||
|
#wget https://cdn.jsdelivr.net/gh/QiuSimons/openwrt-mos@master/luci-app-mosdns/root/etc/mosdns/def_config.yaml -nv -O /tmp/mosdns/def_config.yaml
|
||||||
|
TMPDIR=$(mktemp -d) || exit 2
|
||||||
|
getdat def_config.yaml
|
||||||
|
getdat serverlist.txt
|
||||||
|
|
||||||
|
if [ "$(grep -o .com "$TMPDIR"/serverlist.txt | wc -l)" -lt "1000" ]; then
|
||||||
|
rm -rf "$TMPDIR"/serverlist.txt
|
||||||
|
fi
|
||||||
|
if [ "$(grep -o plugin "$TMPDIR"/def_config.yaml | wc -l)" -eq "0" ]; then
|
||||||
|
rm -rf "$TMPDIR"/def_config.yaml
|
||||||
|
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
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
# shellcheck source=/etc/mosdns/library.sh
|
||||||
|
|
||||||
|
source /etc/mosdns/library.sh
|
||||||
|
|
||||||
|
if L_exist ssrp; then
|
||||||
|
if [ "$1" = "unset" ]; then
|
||||||
|
uci set shadowsocksr.@global[0].pdnsd_enable='1'
|
||||||
|
uci set shadowsocksr.@global[0].tunnel_forward='8.8.4.4:53'
|
||||||
|
elif [ "$1" = "" ]; then
|
||||||
|
uci set shadowsocksr.@global[0].pdnsd_enable='0'
|
||||||
|
uci del shadowsocksr.@global[0].tunnel_forward
|
||||||
|
fi
|
||||||
|
uci commit shadowsocksr
|
||||||
|
if [ "$(pid ssrplus)" ]; then
|
||||||
|
/etc/init.d/shadowsocksr restart
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if L_exist pw; then
|
||||||
|
if [ "$1" = "unset" ]; then
|
||||||
|
uci set passwall.@global[0].dns_mode='pdnsd'
|
||||||
|
uci set passwall.@global[0].dns_forward='8.8.8.8'
|
||||||
|
uci set passwall.@global[0].dns_cache='1'
|
||||||
|
uci set passwall.@global[0].chinadns_ng='1'
|
||||||
|
elif [ "$1" = "" ]; then
|
||||||
|
uci set passwall.@global[0].dns_mode='udp'
|
||||||
|
uci set passwall.@global[0].dns_forward='127.0.0.1:5335'
|
||||||
|
uci del passwall.@global[0].dns_cache
|
||||||
|
uci set passwall.@global[0].chinadns_ng='0'
|
||||||
|
fi
|
||||||
|
uci commit passwall
|
||||||
|
if [ "$(pid passwall)" ]; then
|
||||||
|
/etc/init.d/passwall restart
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if L_exist vssr; then
|
||||||
|
if [ "$1" = "unset" ]; then
|
||||||
|
uci set vssr.@global[0].pdnsd_enable='1'
|
||||||
|
elif [ "$1" = "" ]; then
|
||||||
|
uci set vssr.@global[0].pdnsd_enable='0'
|
||||||
|
fi
|
||||||
|
uci commit vssr
|
||||||
|
if [ "$(pid vssr)" ]; then
|
||||||
|
/etc/init.d/vssr restart
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
exit 0
|
|
@ -0,0 +1,4 @@
|
||||||
|
tracking.miui.com
|
||||||
|
tracking.intl.miui.com
|
||||||
|
api.intl.miui.com
|
||||||
|
stat.xiaomi.com
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
delete ucitrack.@mosdns[-1]
|
||||||
|
add ucitrack mosdns
|
||||||
|
set ucitrack.@mosdns[-1].init=mosdns
|
||||||
|
commit ucitrack
|
||||||
|
EOF
|
||||||
|
|
||||||
|
rm -rf /tmp/luci-*
|
||||||
|
exit 0
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"luci-app-mosdns": {
|
||||||
|
"description": "Grant UCI access for luci-app-mosdns",
|
||||||
|
"read": {
|
||||||
|
"uci": [ "mosdns" ]
|
||||||
|
},
|
||||||
|
"write": {
|
||||||
|
"uci": [ "mosdns" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 ImmortalWrt.org
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=mosdns
|
||||||
|
PKG_VERSION:=35745ff
|
||||||
|
PKG_RELEASE:=$(AUTORELEASE)
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
PKG_SOURCE_URL:=https://codeload.github.com/IrineSistiana/mosdns/tar.gz/$(PKG_VERSION)?
|
||||||
|
PKG_HASH:=skip
|
||||||
|
|
||||||
|
PKG_LICENSE:=GPL-3.0
|
||||||
|
PKG_LICENSE_FILE:=LICENSE
|
||||||
|
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||||
|
|
||||||
|
PKG_CONFIG_DEPENDS:= \
|
||||||
|
CONFIG_MOSDNS_COMPRESS_GOPROXY \
|
||||||
|
CONFIG_MOSDNS_COMPRESS_UPX
|
||||||
|
|
||||||
|
PKG_BUILD_DEPENDS:=golang/host
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_USE_MIPS16:=0
|
||||||
|
|
||||||
|
GO_PKG:=github.com/IrineSistiana/mosdns
|
||||||
|
GO_PKG_LDFLAGS:=-s -w
|
||||||
|
GO_PKG_LDFLAGS_X:=main.version=$(PKG_VERSION)
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||||
|
|
||||||
|
define Package/mosdns/Default
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=IP Addresses and Names
|
||||||
|
TITLE:=A plug-in DNS forwarder/splitter
|
||||||
|
URL:=https://github.com/IrineSistiana/mosdns
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/mosdns
|
||||||
|
$(call Package/mosdns/Default)
|
||||||
|
DEPENDS:=$(GO_ARCH_DEPENDS)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/mosdns/config
|
||||||
|
config MOSDNS_COMPRESS_GOPROXY
|
||||||
|
bool "Compiling with GOPROXY proxy"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config MOSDNS_COMPRESS_UPX
|
||||||
|
bool "Compress executable files with UPX"
|
||||||
|
default y
|
||||||
|
endef
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_MOSDNS_COMPRESS_GOPROXY),y)
|
||||||
|
export GO111MODULE=on
|
||||||
|
export GOPROXY=https://mirrors.aliyun.com/goproxy/
|
||||||
|
endif
|
||||||
|
|
||||||
|
define Build/Prepare
|
||||||
|
$(call Build/Prepare/Default)
|
||||||
|
endef
|
||||||
|
|
||||||
|
GO_PKG_TARGET_VARS:=$(filter-out CGO_ENABLED=%,$(GO_PKG_TARGET_VARS)) CGO_ENABLED=0
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
$(call GoPackage/Build/Compile)
|
||||||
|
ifneq ($(CONFIG_MOSDNS_COMPRESS_UPX),)
|
||||||
|
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/mosdns
|
||||||
|
endif
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/mosdns/install
|
||||||
|
$(call GoPackage/Package/Install/Bin,$(1))
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call GoBinPackage,mosdns))
|
||||||
|
$(eval $(call BuildPackage,mosdns))
|
Loading…
Reference in New Issue