luci-app-mosdns: add local DNS settings
* make up for the defect that Dnsmasq does not support DoH / DoT protocols
This commit is contained in:
parent
6f677a8f9d
commit
fe2caaab18
@ -34,6 +34,44 @@ logfile.placeholder = "/tmp/mosdns.log"
|
|||||||
logfile.default = "/tmp/mosdns.log"
|
logfile.default = "/tmp/mosdns.log"
|
||||||
logfile:depends( "configfile", "/etc/mosdns/config.yaml")
|
logfile:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
|
||||||
|
redirect = s:option(Flag, "redirect", translate("DNS Forward"), translate("Forward Dnsmasq Domain Name resolution requests to MosDNS"))
|
||||||
|
redirect.default = true
|
||||||
|
|
||||||
|
custom_local_dns = s:option(Flag, "custom_local_dns", translate("Local DNS"), translate("Follow WAN interface DNS if not enabled"))
|
||||||
|
custom_local_dns:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
custom_local_dns.default = false
|
||||||
|
|
||||||
|
custom_local_dns = s:option(DynamicList, "local_dns", translate("Upstream DNS servers"))
|
||||||
|
custom_local_dns:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)")
|
||||||
|
custom_local_dns:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)")
|
||||||
|
custom_local_dns:value("223.5.5.5", "223.5.5.5 (AliDNS Primary)")
|
||||||
|
custom_local_dns:value("223.6.6.6", "223.6.6.6 (AliDNS Secondary)")
|
||||||
|
custom_local_dns:value("114.114.114.114", "114.114.114.114 (114DNS Primary)")
|
||||||
|
custom_local_dns:value("114.114.115.115", "114.114.115.115 (114DNS Secondary)")
|
||||||
|
custom_local_dns:value("180.76.76.76", "180.76.76.76 (Baidu DNS)")
|
||||||
|
custom_local_dns:depends("custom_local_dns", "1")
|
||||||
|
|
||||||
|
custom_local_dns = s:option(ListValue, "bootstrap_dns1", translate("Bootstrap DNS servers"))
|
||||||
|
custom_local_dns:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)")
|
||||||
|
custom_local_dns:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)")
|
||||||
|
custom_local_dns:value("223.5.5.5", "223.5.5.5 (AliDNS Primary)")
|
||||||
|
custom_local_dns:value("223.6.6.6", "223.6.6.6 (AliDNS Secondary)")
|
||||||
|
custom_local_dns:value("114.114.114.114", "114.114.114.114 (114DNS Primary)")
|
||||||
|
custom_local_dns:value("114.114.115.115", "114.114.115.115 (114DNS Secondary)")
|
||||||
|
custom_local_dns:value("180.76.76.76", "180.76.76.76 (Baidu DNS)")
|
||||||
|
custom_local_dns.default = "119.29.29.29"
|
||||||
|
custom_local_dns:depends("custom_local_dns", "1")
|
||||||
|
custom_local_dns = s:option(ListValue, "bootstrap_dns2", " ", translate("Bootstrap DNS servers are used to resolve IP addresses of the DoH/DoT resolvers you specify as upstreams"))
|
||||||
|
custom_local_dns:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)")
|
||||||
|
custom_local_dns:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)")
|
||||||
|
custom_local_dns:value("223.5.5.5", "223.5.5.5 (AliDNS Primary)")
|
||||||
|
custom_local_dns:value("223.6.6.6", "223.6.6.6 (AliDNS Secondary)")
|
||||||
|
custom_local_dns:value("114.114.114.114", "114.114.114.114 (114DNS Primary)")
|
||||||
|
custom_local_dns:value("114.114.115.115", "114.114.115.115 (114DNS Secondary)")
|
||||||
|
custom_local_dns:value("180.76.76.76", "180.76.76.76 (Baidu DNS)")
|
||||||
|
custom_local_dns.default = "223.5.5.5"
|
||||||
|
custom_local_dns:depends("custom_local_dns", "1")
|
||||||
|
|
||||||
remote_dns = s:option(DynamicList, "remote_dns", translate("Remote DNS"))
|
remote_dns = s:option(DynamicList, "remote_dns", translate("Remote DNS"))
|
||||||
remote_dns:value("tls://1.1.1.1", "1.1.1.1 (CloudFlare 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://1.0.0.1", "1.0.0.1 (CloudFlare DNS)")
|
||||||
@ -72,9 +110,6 @@ maximum_ttl.datatype = "and(uinteger,min(0))"
|
|||||||
maximum_ttl.default = "0"
|
maximum_ttl.default = "0"
|
||||||
maximum_ttl:depends( "configfile", "/etc/mosdns/config.yaml")
|
maximum_ttl:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
|
||||||
redirect = s:option(Flag, "redirect", translate("Enable DNS Forward"), translate("Forward Dnsmasq Domain Name resolution requests to MosDNS"))
|
|
||||||
redirect.default = true
|
|
||||||
|
|
||||||
adblock = s:option(Flag, "adblock", translate("Enable DNS ADblock"))
|
adblock = s:option(Flag, "adblock", translate("Enable DNS ADblock"))
|
||||||
adblock:depends( "configfile", "/etc/mosdns/config.yaml")
|
adblock:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
adblock.default = false
|
adblock.default = false
|
||||||
|
@ -22,8 +22,8 @@ msgstr "监听端口"
|
|||||||
msgid "Log Level"
|
msgid "Log Level"
|
||||||
msgstr "日志等级"
|
msgstr "日志等级"
|
||||||
|
|
||||||
msgid "Enable DNS Forward"
|
msgid "DNS Forward"
|
||||||
msgstr "启用 DNS 转发"
|
msgstr "DNS 转发"
|
||||||
|
|
||||||
msgid "Forward Dnsmasq Domain Name resolution requests to MosDNS"
|
msgid "Forward Dnsmasq Domain Name resolution requests to MosDNS"
|
||||||
msgstr "将 Dnsmasq 域名解析请求转发到 MosDNS 服务器"
|
msgstr "将 Dnsmasq 域名解析请求转发到 MosDNS 服务器"
|
||||||
@ -109,6 +109,21 @@ msgstr "自定义"
|
|||||||
msgid "Log File"
|
msgid "Log File"
|
||||||
msgstr "日志文件"
|
msgstr "日志文件"
|
||||||
|
|
||||||
|
msgid "Local DNS"
|
||||||
|
msgstr "本地 DNS"
|
||||||
|
|
||||||
|
msgid "Follow WAN interface DNS if not enabled"
|
||||||
|
msgstr "不启用则遵循 WAN 接口 DNS"
|
||||||
|
|
||||||
|
msgid "Upstream DNS servers"
|
||||||
|
msgstr "上游 DNS 服务器"
|
||||||
|
|
||||||
|
msgid "Bootstrap DNS servers"
|
||||||
|
msgstr "Bootstrap DNS 服务器"
|
||||||
|
|
||||||
|
msgid "Bootstrap DNS servers are used to resolve IP addresses of the DoH/DoT resolvers you specify as upstreams"
|
||||||
|
msgstr "Bootstrap DNS 服务器用于解析所指定为上游的 DoH / DoT 解析器的 IP 地址"
|
||||||
|
|
||||||
msgid "Remote DNS"
|
msgid "Remote DNS"
|
||||||
msgstr "远程 DNS"
|
msgstr "远程 DNS"
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ config mosdns 'config'
|
|||||||
option cache_survival_time '259200'
|
option cache_survival_time '259200'
|
||||||
option minimal_ttl '0'
|
option minimal_ttl '0'
|
||||||
option maximum_ttl '0'
|
option maximum_ttl '0'
|
||||||
|
option custom_local_dns '0'
|
||||||
option enable_pipeline '0'
|
option enable_pipeline '0'
|
||||||
list remote_dns 'tls://8.8.8.8'
|
list remote_dns 'tls://8.8.8.8'
|
||||||
list remote_dns 'tls://1.1.1.1'
|
list remote_dns 'tls://1.1.1.1'
|
||||||
|
@ -41,6 +41,9 @@ get_config() {
|
|||||||
config_get minimal_ttl_custom $1 minimal_ttl 0
|
config_get minimal_ttl_custom $1 minimal_ttl 0
|
||||||
config_get redirect $1 redirect 0
|
config_get redirect $1 redirect 0
|
||||||
config_get remote_dns $1 remote_dns "tls://8.8.8.8 tls://1.1.1.1"
|
config_get remote_dns $1 remote_dns "tls://8.8.8.8 tls://1.1.1.1"
|
||||||
|
config_get custom_local_dns $1 custom_local_dns 0
|
||||||
|
config_get bootstrap_dns1 $1 bootstrap_dns1 "119.29.29.29"
|
||||||
|
config_get bootstrap_dns2 $1 bootstrap_dns2 "223.5.5.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
init_yaml() {
|
init_yaml() {
|
||||||
@ -56,6 +59,8 @@ init_yaml() {
|
|||||||
s,maximum_ttl_custom,$maximum_ttl_custom,g; \
|
s,maximum_ttl_custom,$maximum_ttl_custom,g; \
|
||||||
s,adblock,$adblock,g;s,remote_dns_pipeline,$enable_pipeline,g" \
|
s,adblock,$adblock,g;s,remote_dns_pipeline,$enable_pipeline,g" \
|
||||||
/usr/share/mosdns/default.yaml > $CONF
|
/usr/share/mosdns/default.yaml > $CONF
|
||||||
|
[ "$custom_local_dns" -eq 0 ] && sed -i "/bootstrap/d" $CONF || \
|
||||||
|
sed -i "s,bootstrap_dns1,$bootstrap_dns1,g;s,bootstrap_dns2,$bootstrap_dns2,g" $CONF
|
||||||
echo "${local_dns}" > $tmpdir/local_dns.txt
|
echo "${local_dns}" > $tmpdir/local_dns.txt
|
||||||
echo "${remote_dns}" > $tmpdir/remote_dns.txt
|
echo "${remote_dns}" > $tmpdir/remote_dns.txt
|
||||||
sed -i -e '/- addr: local_dns/{r '$tmpdir/local_dns.txt -e';d};/- addr: remote_dns/{r '$tmpdir/remote_dns.txt -e';d}' \
|
sed -i -e '/- addr: local_dns/{r '$tmpdir/local_dns.txt -e';d};/- addr: remote_dns/{r '$tmpdir/remote_dns.txt -e';d}' \
|
||||||
|
@ -55,10 +55,13 @@ plugins:
|
|||||||
maximum_ttl: maximum_ttl_custom
|
maximum_ttl: maximum_ttl_custom
|
||||||
|
|
||||||
- tag: "forward_local"
|
- tag: "forward_local"
|
||||||
type: fast_forward
|
type: forward
|
||||||
args:
|
args:
|
||||||
upstream:
|
upstream:
|
||||||
- addr: local_dns
|
- addr: local_dns
|
||||||
|
bootstrap:
|
||||||
|
- "bootstrap_dns1"
|
||||||
|
- "bootstrap_dns2"
|
||||||
|
|
||||||
- tag: "forward_remote"
|
- tag: "forward_remote"
|
||||||
type: fast_forward
|
type: fast_forward
|
||||||
|
@ -11,16 +11,20 @@ logfile_path() (
|
|||||||
)
|
)
|
||||||
|
|
||||||
interface_dns() (
|
interface_dns() (
|
||||||
peerdns=$(uci -q get network.wan.peerdns)
|
if [ "$(uci -q get mosdns.config.custom_local_dns)" -eq 1 ]; then
|
||||||
proto=$(uci -q get network.wan.proto)
|
uci -q get mosdns.config.local_dns
|
||||||
if [ "$peerdns" = 0 ] || [ "$proto" = "static" ]; then
|
|
||||||
uci -q get network.wan.dns
|
|
||||||
else
|
else
|
||||||
interface_status=$(ubus call network.interface.wan status)
|
peerdns=$(uci -q get network.wan.peerdns)
|
||||||
echo $interface_status | jsonfilter -e "@['dns-server'][0]"
|
proto=$(uci -q get network.wan.proto)
|
||||||
echo $interface_status | jsonfilter -e "@['dns-server'][1]"
|
if [ "$peerdns" = 0 ] || [ "$proto" = "static" ]; then
|
||||||
|
uci -q get network.wan.dns
|
||||||
|
else
|
||||||
|
interface_status=$(ubus call network.interface.wan status)
|
||||||
|
echo $interface_status | jsonfilter -e "@['dns-server'][0]"
|
||||||
|
echo $interface_status | jsonfilter -e "@['dns-server'][1]"
|
||||||
|
fi
|
||||||
|
[ $? -ne 0 ] && echo "119.29.29.29"
|
||||||
fi
|
fi
|
||||||
[ $? -ne 0 ] && echo "119.29.29.29"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ad_block() (
|
ad_block() (
|
||||||
|
Loading…
Reference in New Issue
Block a user