🐤 Sync 2024-07-28 20:29:02

This commit is contained in:
github-actions[bot] 2024-07-28 20:29:02 +08:00
parent ae789dcd0d
commit 5e50949fa7
9 changed files with 144 additions and 45 deletions

View File

@ -6,11 +6,11 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=daed
PKG_VERSION=0.6.0
PKG_RELEASE:=60
PKG_RELEASE:=61
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/daeuniverse/daed.git
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
PKG_SOURCE_VERSION:=740cf4298d044720afd7647b69f5e17ee7d89f87
PKG_MIRROR_HASH:=skip
PKG_LICENSE:=AGPL-3.0-only MIT

View File

@ -150,20 +150,25 @@ o.rmempty = false
o.default = false
o:depends("configfile", "/var/etc/mosdns.json")
o = s:taboption("advanced", Value, "cache_size", translate("DNS Cache Size"), translate("DNS cache size (in piece). To disable caching, please set to 0."))
o = s:taboption("advanced", Flag, "cache", translate("Enable DNS Cache"))
o.rmempty = false
o.default = false
o:depends("configfile", "/var/etc/mosdns.json")
o = s:taboption("advanced", Value, "cache_size", translate("DNS Cache Size"), translate("DNS cache size (in piece)."))
o.datatype = "and(uinteger,min(0))"
o.default = "8000"
o:depends("configfile", "/var/etc/mosdns.json")
o:depends("cache", "1")
o = s:taboption("advanced", Value, "lazy_cache_ttl", translate("Lazy Cache TTL"), translate("Lazy cache survival time (in second). To disable Lazy Cache, please set to 0."))
o.datatype = "and(uinteger,min(0))"
o.default = "86400"
o:depends("configfile", "/var/etc/mosdns.json")
o:depends("cache", "1")
o = s:taboption("advanced", Flag, "dump_file", translate("Cache Dump"), translate("Save the cache locally and reload the cache dump on the next startup"))
o.rmempty = false
o.default = false
o:depends("configfile", "/var/etc/mosdns.json")
o:depends("cache", "1")
o = s:taboption("advanced", Value, "dump_interval", translate("Auto Save Cache Interval"))
o.datatype = "and(uinteger,min(0))"

View File

@ -292,11 +292,14 @@ msgstr "防止 DNS 泄漏"
msgid "Enable this option fallback policy forces forwarding to remote DNS"
msgstr "启用此选项 fallback 策略会强制转发到远程 DNS"
msgid "Enable DNS Cache"
msgstr "启用 DNS 缓存"
msgid "DNS Cache Size"
msgstr "DNS 缓存大小"
msgid "DNS cache size (in piece). To disable caching, please set to 0."
msgstr "DNS 缓存大小(单位:条),要禁用缓存,请设置为 0"
msgid "DNS cache size (in piece)."
msgstr "DNS 缓存大小(单位:条)"
msgid "Lazy Cache TTL"
msgstr "乐观缓存 TTL"

View File

@ -11,9 +11,7 @@ config mosdns 'config'
option configfile '/var/etc/mosdns.json'
option log_level 'info'
option log_file '/var/log/mosdns.log'
option cache_size '8000'
option lazy_cache_ttl '86400'
option dump_file '0'
option cache '0'
option concurrent '1'
option idle_timeout '30'
option minimal_ttl '0'

View File

@ -33,6 +33,7 @@ get_config() {
config_get enabled $1 enabled 0
config_get adblock $1 adblock 0
config_get ad_source $1 ad_source ""
config_get cache $1 cache 0
config_get cache_size $1 cache_size 8000
config_get lazy_cache_ttl $1 lazy_cache_ttl 86400
config_get dump_file $1 dump_file 0
@ -231,18 +232,20 @@ generate_config() {
json_close_object
json_close_object
# plugin: lazy_cache
json_add_object
json_add_string "tag" "lazy_cache"
json_add_string "type" "cache"
json_add_object "args"
json_add_int "size" "$cache_size"
json_add_int "lazy_cache_ttl" "$lazy_cache_ttl"
[ "$dump_file" -eq 1 ] && {
json_add_string "dump_file" "/etc/mosdns/cache.dump"
json_add_int "dump_interval" "$dump_interval"
[ "$cache" -eq 1 ] && {
json_add_object
json_add_string "tag" "lazy_cache"
json_add_string "type" "cache"
json_add_object "args"
json_add_int "size" "$cache_size"
json_add_int "lazy_cache_ttl" "$lazy_cache_ttl"
[ "$dump_file" -eq 1 ] && {
json_add_string "dump_file" "/etc/mosdns/cache.dump"
json_add_int "dump_interval" "$dump_interval"
}
json_close_object
json_close_object
}
json_close_object
json_close_object
# plugin: forward_xinfeng_udp
json_add_object
json_add_string "tag" "forward_xinfeng_udp"
@ -573,15 +576,17 @@ generate_config() {
json_add_object
json_add_string "exec" "jump has_resp_sequence"
json_close_object
json_add_object
json_add_array "matches"
json_add_string "" "!qname \$ddnslist"
json_add_string "" "!qname \$blocklist"
json_add_string "" "!qname \$adlist"
json_add_string "" "!qname \$local_ptr"
json_close_array
json_add_string "exec" "\$lazy_cache"
json_close_object
[ "$cache" -eq 1 ] && {
json_add_object
json_add_array "matches"
json_add_string "" "!qname \$ddnslist"
json_add_string "" "!qname \$blocklist"
json_add_string "" "!qname \$adlist"
json_add_string "" "!qname \$local_ptr"
json_close_array
json_add_string "exec" "\$lazy_cache"
json_close_object
}
json_add_object
json_add_string "exec" "\$redirect"
json_close_object

View File

@ -85,6 +85,35 @@ local doh_validate = function(self, value, t)
return nil, translate("DoH request address") .. " " .. translate("Format must be:") .. " URL,IP"
end
local chinadns_dot_validate = function(self, value, t)
if value ~= "" then
value = api.trim(value)
-- Define patterns for IPv4, IPv6, domain, and port
local ipv4_pattern = "(%d+%.%d+%.%d+%.%d+)"
local ipv6_pattern = "([%[%]a-fA-F0-9:]+)" -- IPv6 addresses are wrapped in []
local domain_pattern = "([%w-_%.]+)"
local port_pattern = "(%d+)"
-- Define patterns for the different formats
local patterns = {
"^tls://" .. domain_pattern .. "@" .. ipv4_pattern .. "#" .. port_pattern .. "$", -- tls://域名@ip#端口
"^tls://" .. ipv4_pattern .. "#" .. port_pattern .. "$", -- tls://ip#端口
"^tls://" .. domain_pattern .. "@" .. ipv4_pattern .. "$", -- tls://域名@ip
"^tls://" .. ipv4_pattern .. "$", -- tls://ip
"^tls://" .. domain_pattern .. "@" .. ipv6_pattern .. "#" .. port_pattern .. "$", -- tls://域名@[IPv6]#端口
"^tls://" .. ipv6_pattern .. "#" .. port_pattern .. "$", -- tls://[IPv6]#端口
"^tls://" .. domain_pattern .. "@" .. ipv6_pattern .. "$", -- tls://域名@[IPv6]
"^tls://" .. ipv6_pattern .. "$" -- tls://[IPv6]
}
-- Check if the string matches any of the patterns
for _, pattern in ipairs(patterns) do
if value:match(pattern) then
return value
end
end
return nil, translate("Direct DNS") .. " DoT " .. translate("Format must be:") .. " tls://Domain@IP(#Port) or tls://IP(#Port)"
end
end
m:append(Template(appname .. "/global/status"))
s = m:section(TypedSection, "global")
@ -266,20 +295,48 @@ dns_shunt = s:taboption("DNS", ListValue, "dns_shunt", "DNS " .. translate("Shun
dns_shunt:value("dnsmasq", "Dnsmasq")
dns_shunt:value("chinadns-ng", "Dnsmasq + ChinaDNS-NG")
o = s:taboption("DNS", Value, "direct_dns", translate("Direct DNS"))
o.datatype = "or(ipaddr,ipaddrport)"
o = s:taboption("DNS", ListValue, "direct_dns_mode", translate("Direct DNS") .. " " .. translate("Request protocol"))
o.default = ""
o:value("", translate("Auto"))
o:value("223.5.5.5")
o:value("223.6.6.6")
o:value("114.114.114.114")
o:value("119.29.29.29")
o:value("180.76.76.76")
o:value("1.12.12.12")
o:value("120.53.53.53")
o:value("udp", "UDP")
o:value("tcp", "TCP")
if os.execute("chinadns-ng -V | grep -i wolfssl >/dev/null") == 0 then
o:value("dot", "DoT")
end
--TO DO
--o:value("doh", "DoH")
o:depends({dns_shunt = "dnsmasq"})
o:depends({dns_shunt = "chinadns-ng"})
o = s:taboption("DNS", Value, "direct_dns_udp", translate("Direct DNS"))
o.datatype = "or(ipaddr,ipaddrport)"
o.default = "223.5.5.5"
o:value("223.5.5.5")
o:value("223.6.6.6")
o:value("119.29.29.29")
o:value("180.184.1.1")
o:value("180.184.2.2")
o:value("114.114.114.114")
o:depends("direct_dns_mode", "udp")
o = s:taboption("DNS", Value, "direct_dns_tcp", translate("Direct DNS"))
o.datatype = "or(ipaddr,ipaddrport)"
o.default = "223.5.5.5"
o:value("223.5.5.5")
o:value("223.6.6.6")
o:value("180.184.1.1")
o:value("180.184.2.2")
o:depends("direct_dns_mode", "tcp")
o = s:taboption("DNS", Value, "direct_dns_dot", translate("Direct DNS"))
o.default = "tls://dot.pub@1.12.12.12"
o:value("tls://dot.pub@1.12.12.12")
o:value("tls://dot.pub@120.53.53.53")
o:value("tls://dot.360.cn@36.99.170.86")
o:value("tls://dot.360.cn@101.198.191.4")
o.validate = chinadns_dot_validate
o:depends("direct_dns_mode", "dot")
o = s:taboption("DNS", Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"), translate("Experimental feature."))
o.default = "0"

View File

@ -1298,6 +1298,38 @@ stop_crontab() {
start_dns() {
echolog "DNS域名解析"
local direct_dns_mode=$(config_t_get global direct_dns_mode "auto")
case "$direct_dns_mode" in
udp)
LOCAL_DNS=$(config_t_get global direct_dns_udp 223.5.5.5 | sed 's/:/#/g')
;;
tcp)
LOCAL_DNS="127.0.0.1#${dns_listen_port}"
dns_listen_port=$(expr $dns_listen_port + 1)
local DIRECT_DNS=$(config_t_get global direct_dns_tcp 223.5.5.5 | sed 's/:/#/g')
ln_run "$(first_type dns2tcp)" dns2tcp "/dev/null" -L "${LOCAL_DNS}" -R "$(get_first_dns DIRECT_DNS 53)" -v
echolog " - dns2tcp(${LOCAL_DNS}) -> tcp://$(get_first_dns DIRECT_DNS 53 | sed 's/#/:/g')"
echolog " * 请确保上游直连 DNS 支持 TCP 查询。"
;;
dot)
if [ "$(chinadns-ng -V | grep -i wolfssl)" != "nil" ]; then
LOCAL_DNS="127.0.0.1#${dns_listen_port}"
local cdns_listen_port=${dns_listen_port}
dns_listen_port=$(expr $dns_listen_port + 1)
local DIRECT_DNS=$(config_t_get global direct_dns_dot "tls://dot.pub@1.12.12.12")
ln_run "$(first_type chinadns-ng)" chinadns-ng "/dev/null" -b 127.0.0.1 -l ${cdns_listen_port}@udp -c ${DIRECT_DNS} -d chn
echolog " - ChinaDNS-NG(${LOCAL_DNS}) -> ${DIRECT_DNS}"
echolog " * 请确保上游直连 DNS 支持 DoT 查询。"
else
echolog " - 你的ChinaDNS-NG版本不支持DoT直连DNS将使用默认UDP地址。"
fi
;;
auto)
#Automatic logic is already done by default
:
;;
esac
TUN_DNS="127.0.0.1#${dns_listen_port}"
[ "${resolve_dns}" == "1" ] && TUN_DNS="127.0.0.1#${resolve_dns_port}"
@ -1880,9 +1912,6 @@ DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | a
DEFAULT_DNS=$(uci show dhcp.@dnsmasq[0] | grep "\.server=" | awk -F '=' '{print $2}' | sed "s/'//g" | tr ' ' '\n' | grep -v "\/" | head -2 | sed ':label;N;s/\n/,/;b label')
[ -z "${DEFAULT_DNS}" ] && [ "$(echo $ISP_DNS | tr ' ' '\n' | wc -l)" -le 2 ] && DEFAULT_DNS=$(echo -n $ISP_DNS | tr ' ' '\n' | head -2 | tr '\n' ',')
LOCAL_DNS="${DEFAULT_DNS:-119.29.29.29,223.5.5.5}"
DIRECT_DNS=$(config_t_get global direct_dns "auto")
#Automatic logic is already done by default
[ "${DIRECT_DNS}" != "auto" ] && LOCAL_DNS=$(echo ${DIRECT_DNS} | sed 's/:/#/g')
DNS_QUERY_STRATEGY="UseIP"
[ "$FILTER_PROXY_IPV6" = "1" ] && DNS_QUERY_STRATEGY="UseIPv4"

View File

@ -6,3 +6,5 @@
180.76.76.76
1.12.12.12
120.53.53.53
180.184.1.1
180.184.2.2

View File

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mihomo
PKG_VERSION:=1.18.6
PKG_RELEASE:=19
PKG_VERSION:=1.18.7
PKG_RELEASE:=20
PKG_BUILD_TIME=$(shell date -u -Iseconds)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz