mirror of
https://github.com/kenzok8/openwrt-packages.git
synced 2025-01-08 11:37:36 +08:00
update 2023-02-02 22:16:03
This commit is contained in:
parent
3691f0abec
commit
87971c4dc9
19
luci-app-mosdns/Makefile
Normal file
19
luci-app-mosdns/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-mosdns
|
||||
PKG_VERSION:=1.5
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI Support for mosdns
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+mosdns-v5 +jsonfilter +bash +luci-compat +zoneinfo-asia
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/mosdns/cus_config.yaml
|
||||
/etc/config/mosdns
|
||||
/etc/mosdns/rule
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
34
luci-app-mosdns/luasrc/controller/mosdns.lua
Normal file
34
luci-app-mosdns/luasrc/controller/mosdns.lua
Normal file
@ -0,0 +1,34 @@
|
||||
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", "rule_list"}, cbi("mosdns/rule_list"), _("Rule List"), 2).leaf = true
|
||||
entry({"admin", "services", "mosdns", "update"}, cbi("mosdns/update"), _("Geodata Update"), 3).leaf = true
|
||||
entry({"admin", "services", "mosdns", "log"}, cbi("mosdns/log"), _("Logs"), 4).leaf = true
|
||||
entry({"admin", "services", "mosdns", "status"}, call("act_status")).leaf = true
|
||||
entry({"admin", "services", "mosdns", "get_log"}, call("get_log")).leaf = true
|
||||
entry({"admin", "services", "mosdns", "clear_log"}, call("clear_log")).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
|
||||
|
||||
function get_log()
|
||||
luci.http.write(luci.sys.exec("cat $(/etc/mosdns/lib.sh logfile)"))
|
||||
end
|
||||
|
||||
function clear_log()
|
||||
luci.sys.call("true > $(/etc/mosdns/lib.sh logfile)")
|
||||
end
|
85
luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua
Normal file
85
luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua
Normal file
@ -0,0 +1,85 @@
|
||||
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"
|
||||
|
||||
listenport = s:option(Value, "listen_port", translate("Listen port"))
|
||||
listenport.datatype = "and(port,min(1))"
|
||||
listenport.default = 5335
|
||||
listenport:depends( "configfile", "./def_config.yaml")
|
||||
|
||||
loglv = s:option(ListValue, "loglv", translate("Log Level"))
|
||||
loglv:value("debug", translate("Debug"))
|
||||
loglv:value("info", translate("Info"))
|
||||
loglv:value("warn", translate("Warning"))
|
||||
loglv:value("error", translate("Error"))
|
||||
loglv.default = "error"
|
||||
loglv:depends( "configfile", "./def_config.yaml")
|
||||
|
||||
logfile = s:option(Value, "logfile", translate("MosDNS Log File"))
|
||||
logfile.placeholder = "/tmp/mosdns.txt"
|
||||
logfile.default = "/tmp/mosdns.txt"
|
||||
logfile:depends( "configfile", "./def_config.yaml")
|
||||
|
||||
remote_dns = s:option(Value, "remote_dns1", translate("Remote DNS"))
|
||||
remote_dns.default = "tls://8.8.4.4"
|
||||
remote_dns:value("tls://8.8.8.8", "8.8.8.8 (Google DNS)")
|
||||
remote_dns:value("tls://8.8.4.4", "8.8.4.4 (Google DNS)")
|
||||
remote_dns:value("tls://1.1.1.1", "1.1.1.1 (CloudFlare DNS)")
|
||||
remote_dns:value("tls://1.0.0.1", "1.0.0.1 (CloudFlare DNS)")
|
||||
remote_dns:value("tls://208.67.222.222", "208.67.222.222 (Open DNS)")
|
||||
remote_dns:value("tls://208.67.220.220", "208.67.220.220 (Open DNS)")
|
||||
remote_dns:value("tls://94.140.14.140", "94.140.14.140 (AdGuard)")
|
||||
remote_dns:value("tls://94.140.14.141", "94.140.14.141 (AdGuard)")
|
||||
remote_dns:depends( "configfile", "./def_config.yaml")
|
||||
remote_dns = s:option(Value, "remote_dns2", " ")
|
||||
remote_dns.default = "tls://1.0.0.1"
|
||||
remote_dns:value("tls://8.8.8.8", "8.8.8.8 (Google DNS)")
|
||||
remote_dns:value("tls://8.8.4.4", "8.8.4.4 (Google DNS)")
|
||||
remote_dns:value("tls://1.1.1.1", "1.1.1.1 (CloudFlare DNS)")
|
||||
remote_dns:value("tls://1.0.0.1", "1.0.0.1 (CloudFlare DNS)")
|
||||
remote_dns:value("tls://208.67.222.222", "208.67.222.222 (Open DNS)")
|
||||
remote_dns:value("tls://208.67.220.220", "208.67.220.220 (Open DNS)")
|
||||
remote_dns:value("tls://94.140.14.140", "94.140.14.140 (AdGuard)")
|
||||
remote_dns:value("tls://94.140.14.141", "94.140.14.141 (AdGuard)")
|
||||
remote_dns: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 = false
|
||||
|
||||
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
|
||||
|
||||
return m
|
5
luci-app-mosdns/luasrc/model/cbi/mosdns/log.lua
Normal file
5
luci-app-mosdns/luasrc/model/cbi/mosdns/log.lua
Normal file
@ -0,0 +1,5 @@
|
||||
m = Map("mosdns")
|
||||
|
||||
m:append(Template("mosdns/mosdns_log"))
|
||||
|
||||
return m
|
75
luci-app-mosdns/luasrc/model/cbi/mosdns/rule_list.lua
Normal file
75
luci-app-mosdns/luasrc/model/cbi/mosdns/rule_list.lua
Normal file
@ -0,0 +1,75 @@
|
||||
local datatypes = require "luci.cbi.datatypes"
|
||||
|
||||
local white_list_file = "/etc/mosdns/rule/whitelist.txt"
|
||||
local block_list_file = "/etc/mosdns/rule/blocklist.txt"
|
||||
local hosts_list_file = "/etc/mosdns/rule/hosts.txt"
|
||||
local redirect_list_file = "/etc/mosdns/rule/redirect.txt"
|
||||
local cus_config_file = "/etc/mosdns/cus_config.yaml"
|
||||
|
||||
m = Map("mosdns")
|
||||
|
||||
s = m:section(TypedSection, "mosdns", translate("Rule Settings"))
|
||||
s.anonymous = true
|
||||
|
||||
s:tab("white_list", translate("White Lists"))
|
||||
s:tab("block_list", translate("Block Lists"))
|
||||
s:tab("hosts_list", translate("Hosts"))
|
||||
s:tab("redirect_list", translate("Redirect"))
|
||||
s:tab("cus_config", translate("Cus Config"))
|
||||
|
||||
o = s:taboption("white_list", TextValue, "whitelist", "", "<font color='red'>" .. translate("These domain names allow DNS resolution with the highest priority. Please input the domain names of websites, every line can input only one website domain. For example: hm.baidu.com.") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(white_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(white_list_file , value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(white_list_file , "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("block_list", TextValue, "blocklist", "", "<font color='red'>" .. translate("These domains are blocked from DNS resolution. Please input the domain names of websites, every line can input only one website domain. For example: baidu.com.") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(block_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(block_list_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(block_list_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("hosts_list", TextValue, "hosts", "", "<font color='red'>" .. translate("Hosts For example: baidu.com 10.0.0.1") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(hosts_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(hosts_list_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(hosts_list_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("redirect_list", TextValue, "redirect", "", "<font color='red'>" .. translate("The domain name to redirect the request to. Requests domain A, but returns records for domain B. example: a.com b.com") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(redirect_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(redirect_list_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(redirect_list_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("cus_config", TextValue, "Cus Config", "", "<font color='red'>" .. translate("View the Custom YAML Configuration file used by this MosDNS. You can edit it as you own need.") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Custom Config' profiles.") .. "</font>")
|
||||
o.rows = 30
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(cus_config_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(cus_config_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(cus_config_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
local apply = luci.http.formvalue("cbi.apply")
|
||||
if apply then
|
||||
luci.sys.exec("/etc/init.d/mosdns reload")
|
||||
end
|
||||
|
||||
return m
|
37
luci-app-mosdns/luasrc/model/cbi/mosdns/update.lua
Normal file
37
luci-app-mosdns/luasrc/model/cbi/mosdns/update.lua
Normal file
@ -0,0 +1,37 @@
|
||||
m = Map("mosdns")
|
||||
|
||||
s = m:section(TypedSection, "mosdns", translate("Geodata Update"))
|
||||
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
|
29
luci-app-mosdns/luasrc/view/mosdns/mosdns_log.htm
Normal file
29
luci-app-mosdns/luasrc/view/mosdns/mosdns_log.htm
Normal file
@ -0,0 +1,29 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function clear_log(btn) {
|
||||
XHR.get('<%=url([[admin]], [[services]], [[mosdns]], [[clear_log]])%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = "";
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
);
|
||||
}
|
||||
XHR.poll(1, '<%=url([[admin]], [[services]], [[mosdns]], [[get_log]])%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = x.responseText;
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<fieldset class="cbi-section" id="_log_fieldset">
|
||||
<input class="cbi-button cbi-input-remove" type="button" onclick="clear_log()" value="<%:Clear logs%>" style="margin-left: 10px; margin-top: 10px;">
|
||||
<textarea id="log_textarea" class="cbi-input-textarea" style="width: calc(100% - 20px); height: 600px; margin: 10px;" data-update="change" rows="5" wrap="off" readonly="readonly"></textarea>
|
||||
</fieldset>
|
28
luci-app-mosdns/luasrc/view/mosdns/mosdns_status.htm
Normal file
28
luci-app-mosdns/luasrc/view/mosdns/mosdns_status.htm
Normal file
@ -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>
|
152
luci-app-mosdns/po/zh-cn/mosdns.po
Normal file
152
luci-app-mosdns/po/zh-cn/mosdns.po
Normal file
@ -0,0 +1,152 @@
|
||||
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 "View the Custom YAML Configuration file used by this MosDNS. You can edit it as you own need."
|
||||
msgstr "注意!此页的更改仅当 'MosDNS 配置文件选择' 为 '自定义配置' 时才会生效"
|
||||
|
||||
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 "Log Level"
|
||||
msgstr "日志级别"
|
||||
|
||||
msgid "MosDNS Log File"
|
||||
msgstr "日志文件"
|
||||
|
||||
msgid "Remote DNS"
|
||||
msgstr "远程 DNS"
|
||||
|
||||
msgid "Listen port"
|
||||
msgstr "监听端口"
|
||||
|
||||
msgid "Rule List"
|
||||
msgstr "规则列表"
|
||||
|
||||
msgid "Rule Settings"
|
||||
msgstr "自定义规则列表"
|
||||
|
||||
msgid "<br>The list of rules only apply to 'Custom Config' profiles."
|
||||
msgstr "<br>规则列表仅适用于 “自定义配置” 配置文件"
|
||||
|
||||
msgid "<br>The list of rules only apply to 'Default Config' profiles."
|
||||
msgstr "<br>规则列表仅适用于 “内置预设” 配置文件"
|
||||
|
||||
msgid "White Lists"
|
||||
msgstr "白名单"
|
||||
|
||||
msgid "These domain names allow DNS resolution with the highest priority. Please input the domain names of websites, every line can input only one website domain. For example: hm.baidu.com."
|
||||
msgstr "加入的域名始终允许 DNS 解析,且优先级最高(每个域名一行,允许使用规则匹配)"
|
||||
|
||||
msgid "Block Lists"
|
||||
msgstr "黑名单"
|
||||
|
||||
msgid "These domains are blocked from DNS resolution. Please input the domain names of websites, every line can input only one website domain. For example: baidu.com."
|
||||
msgstr "加入的域名将屏蔽 DNS 解析(每个域名一行,允许使用规则匹配)"
|
||||
|
||||
msgid "Hosts For example: baidu.com 10.0.0.1"
|
||||
msgstr "自定义 Hosts 重写,如:baidu.com 10.0.0.1(每个规则一行)"
|
||||
|
||||
msgid "Redirect"
|
||||
msgstr "重定向"
|
||||
|
||||
msgid "The domain name to redirect the request to. Requests domain A, but returns records for domain B. example: a.com b.com"
|
||||
msgstr "重定向请求的域名。请求域名 A,但返回域名 B 的记录,如:baidu.com qq.com(每个规则一行)"
|
||||
|
||||
msgid "Logs"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Clear logs"
|
||||
msgstr "清空日志"
|
1
luci-app-mosdns/po/zh_Hans
Symbolic link
1
luci-app-mosdns/po/zh_Hans
Symbolic link
@ -0,0 +1 @@
|
||||
zh-cn
|
17
luci-app-mosdns/root/etc/config/mosdns
Normal file
17
luci-app-mosdns/root/etc/config/mosdns
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
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 'info'
|
||||
option logfile '/tmp/mosdns.txt'
|
||||
option remote_dns1 'tls://8.8.4.4'
|
||||
option remote_dns2 'tls://1.0.0.1'
|
||||
option listen_port '5335'
|
2
luci-app-mosdns/root/etc/hotplug.d/iface/65-mosdns
Executable file
2
luci-app-mosdns/root/etc/hotplug.d/iface/65-mosdns
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
[ "$ACTION" = ifup ] && /etc/init.d/mosdns restart
|
153
luci-app-mosdns/root/etc/init.d/mosdns
Executable file
153
luci-app-mosdns/root/etc/init.d/mosdns
Executable file
@ -0,0 +1,153 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2020 IrineSistiana
|
||||
# shellcheck disable=SC2034
|
||||
|
||||
START=99
|
||||
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 del dhcp.@dnsmasq[0].setbymosdns
|
||||
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#$(uci -q get mosdns.mosdns.listen_port)"
|
||||
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 set dhcp.@dnsmasq[0].setbymosdns='1'
|
||||
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
|
||||
crontab $CRON_FILE
|
||||
}
|
||||
|
||||
adblock() {
|
||||
cp -f /etc/mosdns/rule/serverlist.txt /etc/mosdns/rule/serverlist.bak
|
||||
modns_adblock=$(uci -q get mosdns.mosdns.adblock)
|
||||
if [ "$modns_adblock" = 0 ]; then
|
||||
: > /etc/mosdns/rule/serverlist.txt
|
||||
else
|
||||
cat /etc/mosdns/rule/serverlist.bak > /etc/mosdns/rule/serverlist.txt
|
||||
fi
|
||||
}
|
||||
|
||||
v4config() {
|
||||
rm -rf /etc/mosdns/def_config.yaml
|
||||
cp -rf /etc/mosdns/def_config_orig.yaml /etc/mosdns/def_config.yaml
|
||||
sed -i "s,listenport,$(uci -q get mosdns.mosdns.listen_port),g" /etc/mosdns/def_config.yaml
|
||||
sed -i "s,loglvl,$(uci -q get mosdns.mosdns.loglv),g" /etc/mosdns/def_config.yaml
|
||||
sed -i "s,logfile,$(uci -q get mosdns.mosdns.logfile),g" /etc/mosdns/def_config.yaml
|
||||
sed -i "s,remotedns1,$(uci -q get mosdns.mosdns.remote_dns1),g" /etc/mosdns/def_config.yaml
|
||||
sed -i "s,remotedns2,$(uci -q get mosdns.mosdns.remote_dns2),g" /etc/mosdns/def_config.yaml
|
||||
sed -i "s,localdns1,$(/etc/mosdns/lib.sh dns 0),g" /etc/mosdns/def_config.yaml
|
||||
sed -i "s,localdns2,$(/etc/mosdns/lib.sh dns 1),g" /etc/mosdns/def_config.yaml
|
||||
}
|
||||
|
||||
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
|
||||
true > "$(/etc/mosdns/lib.sh logfile)"
|
||||
sysctl -w net.core.rmem_max=2500000
|
||||
v4config
|
||||
procd_open_instance mosdns
|
||||
procd_set_param command $PROG start -d $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
|
||||
true > /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" ] && [ "$(uci -q get dhcp.@dnsmasq[0].setbymosdns)" -eq 1 ] && restore_setting
|
||||
restart_others
|
||||
fi
|
||||
delcron
|
||||
|
||||
}
|
31
luci-app-mosdns/root/etc/mosdns/cus_config.yaml
Normal file
31
luci-app-mosdns/root/etc/mosdns/cus_config.yaml
Normal file
@ -0,0 +1,31 @@
|
||||
# 日志设置
|
||||
log:
|
||||
level: info # 日志级别。可选 "debug" "info" "warn" "error"。默认 "info"。
|
||||
file: "/path/to/log/file" # 记录日志到文件。
|
||||
|
||||
# 数据源设置
|
||||
data_providers:
|
||||
- tag: data1 # 数据源的 tag。由用户自由设定。不能重复。
|
||||
file: "/path/to/data/file" # 文件位置
|
||||
auto_reload: true # 文件有变化时是否自动重载。
|
||||
|
||||
# 插件设置
|
||||
plugins:
|
||||
- tag: tag1 # 插件的 tag。由用户自由设定。不能重复。
|
||||
type: type1 # 插件类型。详见下文。
|
||||
args: # 插件参数。取决于插件类型。详见下文。
|
||||
key1: value1
|
||||
key2: value2
|
||||
|
||||
# 服务器设置
|
||||
servers:
|
||||
- exec: tag1 # 本服务器运行插件的 tag。
|
||||
timeout: 5 # 请求处理超时时间。单位: 秒。默认: 5。
|
||||
listener: # 监听设置
|
||||
- protocol: https # 协议,支持 "udp", "tcp", "tls", "https" 和 "http"
|
||||
addr: ":443" # 监听地址。
|
||||
cert: "/path/to/my/cert" # TLS 所需证书文件。
|
||||
key: "/path/to/my/key" # TLS 所需密钥文件。
|
||||
url_path: "/dns-query" # DoH 路径。
|
||||
get_user_ip_from_header: "X-Forwarded-For" # DoH 尝试从 HTTP 头获取用户 IP。
|
||||
idle_timeout: 10 # 连接复用空连接超时时间。单位: 秒。默认: 10。
|
206
luci-app-mosdns/root/etc/mosdns/def_config_orig.yaml
Normal file
206
luci-app-mosdns/root/etc/mosdns/def_config_orig.yaml
Normal file
@ -0,0 +1,206 @@
|
||||
log:
|
||||
level: loglvl
|
||||
file: "logfile"
|
||||
|
||||
# api:
|
||||
# http: "127.0.0.1:8080" # 在该地址启动 api 接口。
|
||||
|
||||
plugins:
|
||||
# 加载配置
|
||||
# 国内域名
|
||||
- tag: geosite_cn
|
||||
type: domain_set
|
||||
args:
|
||||
files: # 从文本文件载入
|
||||
- "/etc/mosdns/rule/geosite_cn.txt"
|
||||
|
||||
# 国内ip
|
||||
- tag: geoip_cn
|
||||
type: ip_set
|
||||
args:
|
||||
files: # 从文本文件载入
|
||||
- "/etc/mosdns/rule/geoip_cn.txt"
|
||||
|
||||
# 国外域名
|
||||
- tag: geosite_no_cn
|
||||
type: domain_set
|
||||
args:
|
||||
files: # 从文本文件载入
|
||||
- "/etc/mosdns/rule/geosite_no_cn.txt"
|
||||
|
||||
# 白名单 加入的域名始终允许使用 “本地 DNS” 进行解析
|
||||
- tag: whitelist
|
||||
type: domain_set
|
||||
args:
|
||||
files: # 从文本文件载入
|
||||
- "/etc/mosdns/rule/whitelist.txt"
|
||||
|
||||
# 黑名单 加入的域名将屏蔽 DNS 解析
|
||||
- tag: blocklist
|
||||
type: domain_set
|
||||
args:
|
||||
files: # 从文本文件载入
|
||||
- "/etc/mosdns/rule/blocklist.txt"
|
||||
|
||||
# 自定义 Hosts 重写
|
||||
- tag: hosts
|
||||
type: hosts
|
||||
args:
|
||||
files: # 从文本文件载入
|
||||
- "/etc/mosdns/rule/hosts.txt"
|
||||
|
||||
# 重定向请求的域名
|
||||
- tag: redirect
|
||||
type: redirect
|
||||
args:
|
||||
files:
|
||||
- "/etc/mosdns/rule/redirect.txt"
|
||||
|
||||
# 广告列表
|
||||
- tag: adlist
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/etc/mosdns/rule/serverlist.txt"
|
||||
|
||||
# 缓存
|
||||
- tag: cache
|
||||
type: cache
|
||||
args:
|
||||
size: 200000
|
||||
lazy_cache_ttl: 259200
|
||||
|
||||
# 转发至本地服务器
|
||||
- tag: forward_local
|
||||
type: forward
|
||||
args:
|
||||
upstreams:
|
||||
- addr: localdns1
|
||||
- addr: localdns2
|
||||
|
||||
# 转发至远程服务器
|
||||
- tag: forward_remote
|
||||
type: forward
|
||||
args:
|
||||
upstreams:
|
||||
- addr: remotedns1
|
||||
enable_pipeline: true
|
||||
- addr: remotedns2
|
||||
enable_pipeline: true
|
||||
|
||||
# 国内解析
|
||||
- tag: local_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $forward_local
|
||||
|
||||
# 国外解析
|
||||
- tag: remote_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- exec: prefer_ipv4
|
||||
- exec: $forward_remote
|
||||
|
||||
# 有响应终止返回
|
||||
- tag: has_resp_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- matches: has_resp
|
||||
exec: accept
|
||||
|
||||
|
||||
# fallback 用本地服务器 sequence
|
||||
# 返回不包含本地 ip 则 reject
|
||||
- tag: query_is_local_ip
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $local_sequence
|
||||
- matches: resp_ip $geoip_cn
|
||||
exec: accept
|
||||
- exec: reject
|
||||
|
||||
# fallback 用远程服务器 sequence
|
||||
- tag: query_is_remote
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $remote_sequence
|
||||
- exec: accept
|
||||
|
||||
# fallback 用远程服务器 sequence
|
||||
- tag: fallback
|
||||
type: fallback
|
||||
args:
|
||||
primary: query_is_local_ip
|
||||
secondary: query_is_remote
|
||||
threshold: 150
|
||||
always_standby: true
|
||||
|
||||
|
||||
# 查询国内域名
|
||||
- tag: query_is_local_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $geosite_cn
|
||||
exec: $local_sequence
|
||||
|
||||
# 查询国外域名
|
||||
- tag: query_is_no_local_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $geosite_no_cn
|
||||
exec: $remote_sequence
|
||||
|
||||
# 查询白名单
|
||||
- tag: query_is_whitelist_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $whitelist
|
||||
exec: $local_sequence
|
||||
- exec: jump has_resp_sequence
|
||||
|
||||
# 拒绝名单
|
||||
- tag: query_is_reject_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $blocklist
|
||||
exec: reject 3
|
||||
- matches: qname $adlist
|
||||
exec: reject 3
|
||||
- matches:
|
||||
- qtype 12
|
||||
exec: reject 3
|
||||
- matches: qtype 65
|
||||
exec: reject 3
|
||||
|
||||
# 主要的运行逻辑插件
|
||||
# sequence 插件中调用的插件 tag 必须在 sequence 前定义,
|
||||
# 否则 sequence 找不到对应插件。
|
||||
- tag: main_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $hosts
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $redirect
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_whitelist_domain
|
||||
- exec: $query_is_reject_domain
|
||||
- exec: $cache
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_local_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_no_local_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $fallback
|
||||
|
||||
# 启动 udp 服务器。
|
||||
- tag: udp_server
|
||||
type: udp_server
|
||||
args:
|
||||
entry: main_sequence
|
||||
listen: "127.0.0.1:listenport"
|
||||
# 启动 tcp 服务器。
|
||||
- tag: tcp_server
|
||||
type: tcp_server
|
||||
args:
|
||||
entry: main_sequence
|
||||
listen: "127.0.0.1:listenport"
|
79
luci-app-mosdns/root/etc/mosdns/lib.sh
Executable file
79
luci-app-mosdns/root/etc/mosdns/lib.sh
Executable file
@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC2034 # Unused variables left for readability
|
||||
LAN_DNS0="119.29.29.29"
|
||||
LAN_DNS1="101.226.4.6"
|
||||
WAN_DNS0="8.8.4.4"
|
||||
WAN_DNS1="8.8.8.8"
|
||||
REPO_URL="https://github.com/QiuSimons/openwrt-mos/raw/master/dat"
|
||||
CDN_URL="https://gh.404delivr.workers.dev"
|
||||
DAT_PREFIX="$CDN_URL/$REPO_URL"
|
||||
|
||||
logfile_path() (
|
||||
configfile=$(uci -q get mosdns.mosdns.configfile)
|
||||
if [ "$configfile" = "./def_config.yaml" ]; then
|
||||
uci -q get mosdns.mosdns.logfile
|
||||
else
|
||||
[ ! -f /etc/mosdns/cus_config.yaml ] && exit 1
|
||||
awk '/^log:/{f=1;next}f==1{if($0~/file:/){print;exit}if($0~/^[^ ]/)exit}' /etc/mosdns/cus_config.yaml | grep -Eo "/[^'\"]+"
|
||||
fi
|
||||
)
|
||||
|
||||
ext() {
|
||||
command -v "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
uci_ext() {
|
||||
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" == "pw2" ]; then
|
||||
uci get passwall2.@global[0].enabled &> /dev/null
|
||||
elif [ "$1" == "vssr" ]; then
|
||||
uci get vssr.@global[0].global_server &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
bakdns() {
|
||||
if [ "$1" -eq 0 ]; then
|
||||
echo "$LAN_DNS0"
|
||||
elif [ "$1" -eq 1 ]; then
|
||||
echo "$LAN_DNS1"
|
||||
fi
|
||||
}
|
||||
|
||||
getdat() {
|
||||
if ext curl; then
|
||||
curl -fSLo "$TMPDIR/$1" "$DAT_PREFIX/$1"
|
||||
else
|
||||
wget "$DAT_PREFIX/$1" --no-check-certificate -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"
|
||||
}
|
||||
|
||||
if [ "$1" == "logfile" ]; then
|
||||
logfile_path
|
||||
elif [[ "$1" == "dns" && "$2" -le 1 ]]; then
|
||||
if [ "$(ifconfig | grep -c wan)" = 0 ]; then
|
||||
bakdns "$2"
|
||||
exit 0
|
||||
fi
|
||||
if [[ "$(getdns 0)" =~ ^127\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
getdns "$2" inactive
|
||||
elif [[ "$(getdns "$2")" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
getdns "$2"
|
||||
else
|
||||
bakdns "$2"
|
||||
fi
|
||||
fi
|
45
luci-app-mosdns/root/etc/mosdns/mosupdater.sh
Executable file
45
luci-app-mosdns/root/etc/mosdns/mosupdater.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash -e
|
||||
# shellcheck source=/dev/null
|
||||
set -o pipefail
|
||||
source /etc/mosdns/lib.sh
|
||||
|
||||
TMPDIR=$(mktemp -d) || exit 1
|
||||
getdat geosite_cn.txt
|
||||
getdat geosite_no_cn.txt
|
||||
getdat geoip_cn.txt
|
||||
if [ "$(grep -o cn "$TMPDIR"/geosite_cn.txt | wc -l)" -lt 100 ]; then
|
||||
rm -rf "$TMPDIR"/geosite_cn.txt
|
||||
fi
|
||||
if [ "$(grep -o google "$TMPDIR"/geosite_no_cn.txt | wc -l)" -eq 0 ]; then
|
||||
rm -rf "$TMPDIR"/geosite_no_cn.txt
|
||||
fi
|
||||
cp -rf "$TMPDIR"/* /etc/mosdns/rule
|
||||
rm -rf "$TMPDIR"
|
||||
|
||||
syncconfig=$(uci -q get mosdns.mosdns.syncconfig)
|
||||
if [ "$syncconfig" -eq 1 ]; then
|
||||
TMPDIR=$(mktemp -d) || exit 2
|
||||
getdat def_config_v5.yaml
|
||||
|
||||
if [ "$(grep -o plugin "$TMPDIR"/def_config_v5.yaml | wc -l)" -eq 0 ]; then
|
||||
rm -rf "$TMPDIR"/def_config_v5.yaml
|
||||
else
|
||||
mv "$TMPDIR"/def_config_v5.yaml "$TMPDIR"/def_config_orig.yaml
|
||||
fi
|
||||
cp -rf "$TMPDIR"/* /etc/mosdns
|
||||
rm -rf "$TMPDIR"
|
||||
fi
|
||||
|
||||
adblock=$(uci -q get mosdns.mosdns.adblock)
|
||||
if [ "$adblock" -eq 1 ]; then
|
||||
TMPDIR=$(mktemp -d) || exit 3
|
||||
getdat 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/rule
|
||||
rm -rf /etc/mosdns/rule/serverlist.bak "$TMPDIR"
|
||||
fi
|
||||
|
||||
exit 0
|
0
luci-app-mosdns/root/etc/mosdns/rule/blocklist.txt
Normal file
0
luci-app-mosdns/root/etc/mosdns/rule/blocklist.txt
Normal file
7952
luci-app-mosdns/root/etc/mosdns/rule/geoip_cn.txt
Normal file
7952
luci-app-mosdns/root/etc/mosdns/rule/geoip_cn.txt
Normal file
File diff suppressed because it is too large
Load Diff
66080
luci-app-mosdns/root/etc/mosdns/rule/geosite_cn.txt
Normal file
66080
luci-app-mosdns/root/etc/mosdns/rule/geosite_cn.txt
Normal file
File diff suppressed because it is too large
Load Diff
35123
luci-app-mosdns/root/etc/mosdns/rule/geosite_no_cn.txt
Normal file
35123
luci-app-mosdns/root/etc/mosdns/rule/geosite_no_cn.txt
Normal file
File diff suppressed because it is too large
Load Diff
0
luci-app-mosdns/root/etc/mosdns/rule/hosts.txt
Normal file
0
luci-app-mosdns/root/etc/mosdns/rule/hosts.txt
Normal file
102
luci-app-mosdns/root/etc/mosdns/rule/local-ptr.txt
Normal file
102
luci-app-mosdns/root/etc/mosdns/rule/local-ptr.txt
Normal file
@ -0,0 +1,102 @@
|
||||
# from unbound.conf
|
||||
127.in-addr.arpa
|
||||
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
|
||||
onion
|
||||
test
|
||||
invalid
|
||||
10.in-addr.arpa
|
||||
16.172.in-addr.arpa
|
||||
17.172.in-addr.arpa
|
||||
18.172.in-addr.arpa
|
||||
19.172.in-addr.arpa
|
||||
20.172.in-addr.arpa
|
||||
21.172.in-addr.arpa
|
||||
22.172.in-addr.arpa
|
||||
23.172.in-addr.arpa
|
||||
24.172.in-addr.arpa
|
||||
25.172.in-addr.arpa
|
||||
26.172.in-addr.arpa
|
||||
27.172.in-addr.arpa
|
||||
28.172.in-addr.arpa
|
||||
29.172.in-addr.arpa
|
||||
30.172.in-addr.arpa
|
||||
31.172.in-addr.arpa
|
||||
168.192.in-addr.arpa
|
||||
0.in-addr.arpa
|
||||
254.169.in-addr.arpa
|
||||
2.0.192.in-addr.arpa
|
||||
100.51.198.in-addr.arpa
|
||||
113.0.203.in-addr.arpa
|
||||
255.255.255.255.in-addr.arpa
|
||||
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa
|
||||
d.f.ip6.arpa
|
||||
8.e.f.ip6.arpa
|
||||
9.e.f.ip6.arpa
|
||||
a.e.f.ip6.arpa
|
||||
b.e.f.ip6.arpa
|
||||
8.b.d.0.1.0.0.2.ip6.arpa
|
||||
# 100.64.0.0/10 保留地址
|
||||
64.100.in-addr.arpa
|
||||
65.100.in-addr.arpa
|
||||
66.100.in-addr.arpa
|
||||
67.100.in-addr.arpa
|
||||
68.100.in-addr.arpa
|
||||
69.100.in-addr.arpa
|
||||
70.100.in-addr.arpa
|
||||
71.100.in-addr.arpa
|
||||
72.100.in-addr.arpa
|
||||
73.100.in-addr.arpa
|
||||
74.100.in-addr.arpa
|
||||
75.100.in-addr.arpa
|
||||
76.100.in-addr.arpa
|
||||
77.100.in-addr.arpa
|
||||
78.100.in-addr.arpa
|
||||
79.100.in-addr.arpa
|
||||
80.100.in-addr.arpa
|
||||
81.100.in-addr.arpa
|
||||
82.100.in-addr.arpa
|
||||
83.100.in-addr.arpa
|
||||
84.100.in-addr.arpa
|
||||
85.100.in-addr.arpa
|
||||
86.100.in-addr.arpa
|
||||
87.100.in-addr.arpa
|
||||
88.100.in-addr.arpa
|
||||
89.100.in-addr.arpa
|
||||
90.100.in-addr.arpa
|
||||
91.100.in-addr.arpa
|
||||
92.100.in-addr.arpa
|
||||
93.100.in-addr.arpa
|
||||
94.100.in-addr.arpa
|
||||
95.100.in-addr.arpa
|
||||
96.100.in-addr.arpa
|
||||
97.100.in-addr.arpa
|
||||
98.100.in-addr.arpa
|
||||
99.100.in-addr.arpa
|
||||
100.100.in-addr.arpa
|
||||
101.100.in-addr.arpa
|
||||
102.100.in-addr.arpa
|
||||
103.100.in-addr.arpa
|
||||
104.100.in-addr.arpa
|
||||
105.100.in-addr.arpa
|
||||
106.100.in-addr.arpa
|
||||
107.100.in-addr.arpa
|
||||
108.100.in-addr.arpa
|
||||
109.100.in-addr.arpa
|
||||
110.100.in-addr.arpa
|
||||
111.100.in-addr.arpa
|
||||
112.100.in-addr.arpa
|
||||
113.100.in-addr.arpa
|
||||
114.100.in-addr.arpa
|
||||
115.100.in-addr.arpa
|
||||
116.100.in-addr.arpa
|
||||
117.100.in-addr.arpa
|
||||
118.100.in-addr.arpa
|
||||
119.100.in-addr.arpa
|
||||
120.100.in-addr.arpa
|
||||
121.100.in-addr.arpa
|
||||
122.100.in-addr.arpa
|
||||
123.100.in-addr.arpa
|
||||
124.100.in-addr.arpa
|
||||
125.100.in-addr.arpa
|
||||
126.100.in-addr.arpa
|
||||
127.100.in-addr.arpa
|
0
luci-app-mosdns/root/etc/mosdns/rule/redirect.txt
Normal file
0
luci-app-mosdns/root/etc/mosdns/rule/redirect.txt
Normal file
65392
luci-app-mosdns/root/etc/mosdns/rule/serverlist.txt
Normal file
65392
luci-app-mosdns/root/etc/mosdns/rule/serverlist.txt
Normal file
File diff suppressed because it is too large
Load Diff
29
luci-app-mosdns/root/etc/mosdns/rule/whitelist.txt
Normal file
29
luci-app-mosdns/root/etc/mosdns/rule/whitelist.txt
Normal file
@ -0,0 +1,29 @@
|
||||
tracking.miui.com
|
||||
tracking.intl.miui.com
|
||||
api.intl.miui.com
|
||||
stat.xiaomi.com
|
||||
checkip.synology.com
|
||||
checkipv6.synology.com
|
||||
checkport.synology.com
|
||||
ddns.synology.com
|
||||
account.synology.com
|
||||
whatismyip.akamai.com
|
||||
checkip.dyndns.org
|
||||
teamviewer.com
|
||||
bing.com
|
||||
api.ipify.org
|
||||
epicgames.com
|
||||
emby.kyarucloud.moe
|
||||
ntp.aliyun.com
|
||||
ntp.tencent.com
|
||||
cn.ntp.org.cn
|
||||
ntp.ntsc.ac.cn
|
||||
keyword:sglong
|
||||
keyword:sgshort
|
||||
keyword:sgminorshort
|
||||
keyword:sgaxshort
|
||||
keyword:sgfindershort
|
||||
keyword:apple
|
||||
keyword:aaplimg
|
||||
keyword:itunes
|
||||
keyword:icloud
|
75
luci-app-mosdns/root/etc/mosdns/set.sh
Executable file
75
luci-app-mosdns/root/etc/mosdns/set.sh
Executable file
@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
# shellcheck source=/dev/null
|
||||
source /etc/mosdns/lib.sh
|
||||
|
||||
if uci_ext ssrp; then
|
||||
if [ "$1" = "unset" ]; then
|
||||
uci set shadowsocksr.@global[0].pdnsd_enable='1'
|
||||
uci set shadowsocksr.@global[0].tunnel_forward="$WAN_DNS0:53"
|
||||
elif [ "$1" = "" ]; then
|
||||
if [ "$(uci -q get mosdns.mosdns.listen_port)" -eq 5335 ]; then
|
||||
uci set shadowsocksr.@global[0].pdnsd_enable='0'
|
||||
uci del shadowsocksr.@global[0].tunnel_forward
|
||||
uci del shadowsocksr.@global[0].adblock_url
|
||||
else
|
||||
uci set shadowsocksr.@global[0].pdnsd_enable='1'
|
||||
uci set shadowsocksr.@global[0].tunnel_forward="127.0.0.1:$(uci -q get mosdns.mosdns.listen_port)"
|
||||
fi
|
||||
fi
|
||||
uci commit shadowsocksr
|
||||
if [ "$(pid ssrplus)" ]; then
|
||||
/etc/init.d/shadowsocksr restart
|
||||
fi
|
||||
fi
|
||||
if uci_ext pw; then
|
||||
if [ "$1" = "unset" ]; then
|
||||
uci set passwall.@global[0].dns_mode='dns2tcp'
|
||||
uci set passwall.@global[0].dns_forward="$WAN_DNS1"
|
||||
uci set passwall.@global[0].remote_dns="$WAN_DNS1"
|
||||
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:$(uci -q get mosdns.mosdns.listen_port)"
|
||||
uci set passwall.@global[0].remote_dns="127.0.0.1:$(uci -q get mosdns.mosdns.listen_port)"
|
||||
uci del passwall.@global[0].dns_cache
|
||||
uci del passwall.@global[0].chinadns_ng
|
||||
fi
|
||||
uci commit passwall
|
||||
if [ "$(pid passwall)" ]; then
|
||||
/etc/init.d/passwall restart
|
||||
fi
|
||||
fi
|
||||
|
||||
if uci_ext pw2; then
|
||||
if [ "$1" = "unset" ]; then
|
||||
uci set passwall2.@global[0].direct_dns_protocol='auto'
|
||||
uci del passwall2.@global[0].direct_dns
|
||||
uci set passwall2.@global[0].remote_dns="$WAN_DNS0"
|
||||
uci set passwall2.@global[0].dns_query_strategy='UseIPv4'
|
||||
elif [ "$1" = "" ]; then
|
||||
uci set passwall2.@global[0].direct_dns_protocol='udp'
|
||||
uci set passwall2.@global[0].direct_dns="127.0.0.1:$(uci -q get mosdns.mosdns.listen_port)"
|
||||
uci set passwall2.@global[0].remote_dns_protocol='udp'
|
||||
uci set passwall2.@global[0].remote_dns="127.0.0.1:$(uci -q get mosdns.mosdns.listen_port)"
|
||||
uci set passwall2.@global[0].dns_query_strategy='UseIP'
|
||||
fi
|
||||
uci commit passwall2
|
||||
if [ "$(pid passwall2)" ]; then
|
||||
/etc/init.d/passwall2 restart
|
||||
fi
|
||||
fi
|
||||
|
||||
if uci_ext 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
|
11
luci-app-mosdns/root/etc/uci-defaults/luci-mosdns
Executable file
11
luci-app-mosdns/root/etc/uci-defaults/luci-mosdns
Executable file
@ -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" ]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user