mirror of
https://github.com/kenzok8/small.git
synced 2025-01-07 03:26:39 +08:00
update 2024-12-25 04:13:33
This commit is contained in:
parent
a53f9e076b
commit
d1d5be7451
@ -365,7 +365,38 @@ 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"
|
||||
|
||||
---- DNS Forward Mode
|
||||
o = s:taboption("DNS", ListValue, "dns_mode", translate("Filter Mode"))
|
||||
o:value("udp", translatef("Requery DNS By %s", "UDP"))
|
||||
o:value("tcp", translatef("Requery DNS By %s", "TCP"))
|
||||
if chinadns_tls == 0 then
|
||||
o:value("dot", translatef("Requery DNS By %s", "DoT"))
|
||||
end
|
||||
if api.is_finded("dns2socks") then
|
||||
o:value("dns2socks", "dns2socks")
|
||||
end
|
||||
if has_singbox then
|
||||
o:value("sing-box", "Sing-Box")
|
||||
end
|
||||
if has_xray then
|
||||
o:value("xray", "Xray")
|
||||
end
|
||||
if api.is_finded("smartdns") then
|
||||
o:depends({ dns_shunt = "smartdns", ['!reverse'] = true })
|
||||
end
|
||||
|
||||
---- SmartDNS Forward Mode
|
||||
if api.is_finded("smartdns") then
|
||||
o = s:taboption("DNS", ListValue, "smartdns_dns_mode", translate("Filter Mode"))
|
||||
o:value("socks", "SOCKS")
|
||||
if has_singbox then
|
||||
o:value("sing-box", "Sing-Box")
|
||||
end
|
||||
if has_xray then
|
||||
o:value("xray", "Xray")
|
||||
end
|
||||
o:depends({ dns_shunt = "smartdns" })
|
||||
|
||||
o = s:taboption("DNS", DynamicList, "smartdns_remote_dns", translate("Remote DNS"))
|
||||
o:value("tcp://1.1.1.1")
|
||||
o:value("tcp://8.8.4.4")
|
||||
@ -385,7 +416,7 @@ if api.is_finded("smartdns") then
|
||||
o:value("https://dns.adguard.com/dns-query,176.103.130.130")
|
||||
o:value("https://doh.libredns.gr/dns-query,116.202.176.26")
|
||||
o:value("https://doh.libredns.gr/ads,116.202.176.26")
|
||||
o:depends("dns_shunt", "smartdns")
|
||||
o:depends({ dns_shunt = "smartdns", smartdns_dns_mode = "socks" })
|
||||
o.cfgvalue = function(self, section)
|
||||
return m:get(section, self.option) or {"tcp://1.1.1.1"}
|
||||
end
|
||||
@ -409,35 +440,16 @@ if api.is_finded("smartdns") then
|
||||
end
|
||||
end
|
||||
|
||||
---- DNS Forward Mode
|
||||
o = s:taboption("DNS", ListValue, "dns_mode", translate("Filter Mode"))
|
||||
o:value("udp", translatef("Requery DNS By %s", "UDP"))
|
||||
o:value("tcp", translatef("Requery DNS By %s", "TCP"))
|
||||
if chinadns_tls == 0 then
|
||||
o:value("dot", translatef("Requery DNS By %s", "DoT"))
|
||||
end
|
||||
if api.is_finded("dns2socks") then
|
||||
o:value("dns2socks", "dns2socks")
|
||||
end
|
||||
if has_singbox then
|
||||
o:value("sing-box", "Sing-Box")
|
||||
end
|
||||
if has_xray then
|
||||
o:value("xray", "Xray")
|
||||
end
|
||||
if api.is_finded("smartdns") then
|
||||
o:depends({ dns_shunt = "smartdns", ['!reverse'] = true })
|
||||
end
|
||||
|
||||
o = s:taboption("DNS", ListValue, "xray_dns_mode", translate("Request protocol"))
|
||||
o:value("tcp", "TCP")
|
||||
o:value("tcp+doh", "TCP + DoH (" .. translate("A/AAAA type") .. ")")
|
||||
o:depends("dns_mode", "xray")
|
||||
o:depends("smartdns_dns_mode", "xray")
|
||||
o.cfgvalue = function(self, section)
|
||||
return m:get(section, "v2ray_dns_mode")
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
if s.fields["dns_mode"]:formvalue(section) == "xray" then
|
||||
if s.fields["dns_mode"]:formvalue(section) == "xray" or s.fields["smartdns_dns_mode"]:formvalue(section) == "xray" then
|
||||
return m:set(section, "v2ray_dns_mode", value)
|
||||
end
|
||||
end
|
||||
@ -446,11 +458,12 @@ o = s:taboption("DNS", ListValue, "singbox_dns_mode", translate("Request protoco
|
||||
o:value("tcp", "TCP")
|
||||
o:value("doh", "DoH")
|
||||
o:depends("dns_mode", "sing-box")
|
||||
o:depends("smartdns_dns_mode", "sing-box")
|
||||
o.cfgvalue = function(self, section)
|
||||
return m:get(section, "v2ray_dns_mode")
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
if s.fields["dns_mode"]:formvalue(section) == "sing-box" then
|
||||
if s.fields["dns_mode"]:formvalue(section) == "sing-box" or s.fields["smartdns_dns_mode"]:formvalue(section) == "sing-box" then
|
||||
return m:set(section, "v2ray_dns_mode", value)
|
||||
end
|
||||
end
|
||||
@ -524,16 +537,20 @@ o.description = translate("Notify the DNS server when the DNS query is notified,
|
||||
o.datatype = "ipaddr"
|
||||
o:depends({dns_mode = "sing-box"})
|
||||
o:depends({dns_mode = "xray"})
|
||||
o:depends("smartdns_dns_mode", "sing-box")
|
||||
o:depends("smartdns_dns_mode", "xray")
|
||||
|
||||
o = s:taboption("DNS", Flag, "remote_fakedns", "FakeDNS", translate("Use FakeDNS work in the shunt domain that proxy."))
|
||||
o.default = "0"
|
||||
o:depends({dns_mode = "sing-box", dns_shunt = "dnsmasq"})
|
||||
o:depends({dns_mode = "sing-box", dns_shunt = "chinadns-ng"})
|
||||
o:depends({smartdns_dns_mode = "sing-box", dns_shunt = "smartdns"})
|
||||
o:depends({dns_mode = "xray", dns_shunt = "dnsmasq"})
|
||||
o:depends({dns_mode = "xray", dns_shunt = "chinadns-ng"})
|
||||
o:depends({smartdns_dns_mode = "xray", dns_shunt = "smartdns"})
|
||||
o.validate = function(self, value, t)
|
||||
if value and value == "1" then
|
||||
local _dns_mode = s.fields["dns_mode"]:formvalue(t)
|
||||
local _dns_mode = s.fields["dns_mode"]:formvalue(t) or s.fields["smartdns_dns_mode"]:formvalue(t)
|
||||
local _tcp_node = s.fields["tcp_node"]:formvalue(t)
|
||||
if _dns_mode and _tcp_node then
|
||||
if m:get(_tcp_node, "type"):lower() ~= _dns_mode then
|
||||
|
@ -1406,32 +1406,6 @@ start_dns() {
|
||||
TUN_DNS="127.0.0.1#${dns_listen_port}"
|
||||
[ "${resolve_dns}" == "1" ] && TUN_DNS="127.0.0.1#${resolve_dns_port}"
|
||||
|
||||
[ "${DNS_SHUNT}" = "smartdns" ] && {
|
||||
if command -v smartdns > /dev/null 2>&1; then
|
||||
rm -rf $TMP_PATH2/dnsmasq_default*
|
||||
local group_domestic=$(config_t_get global group_domestic)
|
||||
local smartdns_remote_dns=$(config_t_get global smartdns_remote_dns)
|
||||
if [ -n "${smartdns_remote_dns}" -a "${smartdns_remote_dns}" != "nil" ]; then
|
||||
smartdns_remote_dns=$(echo ${smartdns_remote_dns} | tr -s ' ' '|')
|
||||
else
|
||||
smartdns_remote_dns="tcp://1.1.1.1"
|
||||
fi
|
||||
lua $APP_PATH/helper_smartdns_add.lua -FLAG "default" -SMARTDNS_CONF "/tmp/etc/smartdns/$CONFIG.conf" \
|
||||
-LOCAL_GROUP ${group_domestic:-nil} -REMOTE_GROUP "passwall_proxy" -REMOTE_PROXY_SERVER ${TCP_SOCKS_server} -USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" \
|
||||
-TUN_DNS ${smartdns_remote_dns} \
|
||||
-USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \
|
||||
-TCP_NODE ${TCP_NODE} -DEFAULT_PROXY_MODE "${TCP_PROXY_MODE}" -NO_PROXY_IPV6 ${FILTER_PROXY_IPV6:-0} -NFTFLAG ${nftflag:-0} \
|
||||
-NO_LOGIC_LOG ${NO_LOGIC_LOG:-0}
|
||||
source $APP_PATH/helper_smartdns.sh restart
|
||||
echolog " - 域名解析:使用SmartDNS,请确保配置正常。"
|
||||
return
|
||||
else
|
||||
DNS_SHUNT="dnsmasq"
|
||||
echolog " * 未安装SmartDNS,默认使用Dnsmasq进行域名解析!"
|
||||
fi
|
||||
}
|
||||
rm -rf $TMP_PATH2/smartdns_default*
|
||||
|
||||
case "$DNS_MODE" in
|
||||
dns2socks)
|
||||
local dns2socks_socks_server=$(echo $(config_t_get global socks_server 127.0.0.1:1080) | sed "s/#/:/g")
|
||||
@ -1547,7 +1521,7 @@ start_dns() {
|
||||
echolog " - udp://${TUN_DNS}"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
tcp)
|
||||
use_tcp_node_resolve_dns=1
|
||||
if [ "$DNS_SHUNT" = "chinadns-ng" ] && [ -n "$(first_type chinadns-ng)" ]; then
|
||||
local china_ng_listen_port=${dns_listen_port}
|
||||
@ -1564,6 +1538,32 @@ start_dns() {
|
||||
[ "${use_tcp_node_resolve_dns}" = "1" ] && echolog " * 请确认上游 DNS 支持 TCP/DoT/DoH 查询,如非直连地址,确保 TCP 代理打开,并且已经正确转发!"
|
||||
[ "${use_udp_node_resolve_dns}" = "1" ] && echolog " * 请确认上游 DNS 支持 UDP 查询并已使用 UDP 节点,如上游 DNS 非直连地址,确保 UDP 代理打开,并且已经正确转发!"
|
||||
|
||||
[ "${DNS_SHUNT}" = "smartdns" ] && {
|
||||
if command -v smartdns > /dev/null 2>&1; then
|
||||
rm -rf $TMP_PATH2/dnsmasq_default*
|
||||
local group_domestic=$(config_t_get global group_domestic)
|
||||
local smartdns_remote_dns=$(config_t_get global smartdns_remote_dns)
|
||||
if [ -n "${smartdns_remote_dns}" -a "${smartdns_remote_dns}" != "nil" ]; then
|
||||
smartdns_remote_dns=$(echo ${smartdns_remote_dns} | tr -s ' ' '|')
|
||||
else
|
||||
smartdns_remote_dns="tcp://1.1.1.1"
|
||||
fi
|
||||
lua $APP_PATH/helper_smartdns_add.lua -FLAG "default" -SMARTDNS_CONF "/tmp/etc/smartdns/$CONFIG.conf" \
|
||||
-LOCAL_GROUP ${group_domestic:-nil} -REMOTE_GROUP "passwall_proxy" -REMOTE_PROXY_SERVER ${TCP_SOCKS_server} -USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" \
|
||||
-REMOTE_DNS ${smartdns_remote_dns} -DNS_MODE ${DNS_MODE:-socks} -TUN_DNS ${TUN_DNS} -REMOTE_FAKEDNS ${fakedns:-0} \
|
||||
-USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \
|
||||
-TCP_NODE ${TCP_NODE} -DEFAULT_PROXY_MODE "${TCP_PROXY_MODE}" -NO_PROXY_IPV6 ${FILTER_PROXY_IPV6:-0} -NFTFLAG ${nftflag:-0} \
|
||||
-NO_LOGIC_LOG ${NO_LOGIC_LOG:-0}
|
||||
source $APP_PATH/helper_smartdns.sh restart
|
||||
echolog " - 域名解析:使用SmartDNS,请确保配置正常。"
|
||||
return
|
||||
else
|
||||
DNS_SHUNT="dnsmasq"
|
||||
echolog " * 未安装SmartDNS,默认使用Dnsmasq进行域名解析!"
|
||||
fi
|
||||
}
|
||||
rm -rf $TMP_PATH2/smartdns_default*
|
||||
|
||||
[ "$DNS_SHUNT" = "chinadns-ng" ] && [ -n "$(first_type chinadns-ng)" ] && {
|
||||
chinadns_ng_min=2024.04.13
|
||||
chinadns_ng_now=$(chinadns-ng -V | grep -i "ChinaDNS-NG " | awk '{print $2}')
|
||||
@ -2145,6 +2145,8 @@ CLIENT_PROXY=$(config_t_get global client_proxy 1)
|
||||
DNS_SHUNT=$(config_t_get global dns_shunt dnsmasq)
|
||||
[ -z "$(first_type $DNS_SHUNT)" ] && DNS_SHUNT="dnsmasq"
|
||||
DNS_MODE=$(config_t_get global dns_mode tcp)
|
||||
SMARTDNS_DNS_MODE=$(config_t_get global smartdns_dns_mode socks)
|
||||
[ "$DNS_SHUNT" = "smartdns" ] && DNS_MODE=$SMARTDNS_DNS_MODE
|
||||
DNS_CACHE=0
|
||||
REMOTE_DNS=$(config_t_get global remote_dns 1.1.1.1:53 | sed 's/#/:/g' | sed -E 's/\:([^:]+)$/#\1/g')
|
||||
USE_DEFAULT_DNS=$(config_t_get global use_default_dns direct)
|
||||
|
@ -9,7 +9,10 @@ local LOCAL_GROUP = var["-LOCAL_GROUP"]
|
||||
local REMOTE_GROUP = var["-REMOTE_GROUP"]
|
||||
local REMOTE_PROXY_SERVER = var["-REMOTE_PROXY_SERVER"]
|
||||
local USE_DEFAULT_DNS = var["-USE_DEFAULT_DNS"]
|
||||
local REMOTE_DNS = var["-REMOTE_DNS"]
|
||||
local TUN_DNS = var["-TUN_DNS"]
|
||||
local DNS_MODE = var["-DNS_MODE"]
|
||||
local REMOTE_FAKEDNS = var["-REMOTE_FAKEDNS"]
|
||||
local TCP_NODE = var["-TCP_NODE"]
|
||||
local USE_DIRECT_LIST = var["-USE_DIRECT_LIST"]
|
||||
local USE_PROXY_LIST = var["-USE_PROXY_LIST"]
|
||||
@ -156,8 +159,8 @@ end
|
||||
|
||||
if not REMOTE_GROUP or REMOTE_GROUP == "nil" then
|
||||
REMOTE_GROUP = "passwall_proxy"
|
||||
if TUN_DNS then
|
||||
TUN_DNS = TUN_DNS:gsub("#", ":")
|
||||
if REMOTE_DNS then
|
||||
REMOTE_DNS = REMOTE_DNS:gsub("#", ":")
|
||||
end
|
||||
sys.call('sed -i "/passwall/d" /etc/smartdns/custom.conf >/dev/null 2>&1')
|
||||
end
|
||||
@ -166,10 +169,10 @@ local proxy_server_name = "passwall-proxy-server"
|
||||
config_lines = {
|
||||
"force-qtype-SOA 65",
|
||||
"server 114.114.114.114 -bootstrap-dns",
|
||||
string.format("proxy-server socks5://%s -name %s", REMOTE_PROXY_SERVER, proxy_server_name)
|
||||
DNS_MODE == "socks" and string.format("proxy-server socks5://%s -name %s", REMOTE_PROXY_SERVER, proxy_server_name) or nil
|
||||
}
|
||||
if true then
|
||||
string.gsub(TUN_DNS, '[^' .. "|" .. ']+', function(w)
|
||||
if DNS_MODE == "socks" then
|
||||
string.gsub(REMOTE_DNS, '[^' .. "|" .. ']+', function(w)
|
||||
local server_dns = w
|
||||
local server_param = string.format("server %s -group %s -proxy %s", "%s", REMOTE_GROUP, proxy_server_name)
|
||||
server_param = server_param .. " -exclude-default-group"
|
||||
@ -202,10 +205,15 @@ if true then
|
||||
server_param = string.format(server_param, server_dns)
|
||||
table.insert(config_lines, server_param)
|
||||
end)
|
||||
REMOTE_FAKEDNS = 0
|
||||
else
|
||||
local server_param = string.format("server %s -group %s -exclude-default-group", TUN_DNS:gsub("#", ":"), REMOTE_GROUP)
|
||||
table.insert(config_lines, server_param)
|
||||
log(" - " .. DNS_MODE:gsub("^%l",string.upper) .. " " .. TUN_DNS .. " -> " .. REMOTE_GROUP)
|
||||
end
|
||||
|
||||
--设置默认 DNS 分组(托底组)
|
||||
local DEFAULT_DNS_GROUP = (USE_DEFAULT_DNS == "direct" and LOCAL_GROUP) or
|
||||
local DEFAULT_DNS_GROUP = (USE_DEFAULT_DNS == "direct" and LOCAL_GROUP) or
|
||||
(USE_DEFAULT_DNS == "remote" and REMOTE_GROUP)
|
||||
local only_global = (DEFAULT_PROXY_MODE == "proxy" and CHN_LIST == "0" and USE_GFW_LIST == "0") and 1 --没有启用中国列表和GFW列表时(全局)
|
||||
if only_global == 1 then
|
||||
@ -388,10 +396,10 @@ if USE_PROXY_LIST == "1" and is_file_nonzero(file_proxy_host) then
|
||||
}
|
||||
if NO_PROXY_IPV6 == "1" then
|
||||
domain_rules_str = domain_rules_str .. " -address #6"
|
||||
domain_rules_str = domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")
|
||||
domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str
|
||||
else
|
||||
table.insert(sets, "#6:" .. setflag .. "passwall_black6")
|
||||
domain_rules_str = domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")
|
||||
domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str
|
||||
end
|
||||
table.insert(tmp_lines, domain_rules_str)
|
||||
insert_array_after(config_lines, tmp_lines, "#--5")
|
||||
@ -412,10 +420,10 @@ if USE_GFW_LIST == "1" and is_file_nonzero(RULES_PATH .. "/gfwlist") then
|
||||
}
|
||||
if NO_PROXY_IPV6 == "1" then
|
||||
domain_rules_str = domain_rules_str .. " -address #6"
|
||||
domain_rules_str = domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")
|
||||
domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str
|
||||
else
|
||||
table.insert(sets, "#6:" .. setflag .. "passwall_gfw6")
|
||||
domain_rules_str = domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")
|
||||
domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str
|
||||
end
|
||||
table.insert(tmp_lines, domain_rules_str)
|
||||
insert_array_after(config_lines, tmp_lines, "#--1")
|
||||
@ -452,10 +460,10 @@ if CHN_LIST ~= "0" and is_file_nonzero(RULES_PATH .. "/chnlist") then
|
||||
}
|
||||
if NO_PROXY_IPV6 == "1" then
|
||||
domain_rules_str = domain_rules_str .. " -address #6"
|
||||
domain_rules_str = domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")
|
||||
domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str
|
||||
else
|
||||
table.insert(sets, "#6:" .. setflag .. "passwall_chn6")
|
||||
domain_rules_str = domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")
|
||||
domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str
|
||||
end
|
||||
table.insert(tmp_lines, domain_rules_str)
|
||||
insert_array_after(config_lines, tmp_lines, "#--2")
|
||||
@ -579,10 +587,14 @@ if uci:get(appname, TCP_NODE, "protocol") == "_shunt" then
|
||||
}
|
||||
if NO_PROXY_IPV6 == "1" then
|
||||
domain_rules_str = domain_rules_str .. " -address #6"
|
||||
domain_rules_str = domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")
|
||||
domain_rules_str = (not only_global and REMOTE_FAKEDNS == "1")
|
||||
and domain_rules_str
|
||||
or (domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ","))
|
||||
else
|
||||
table.insert(sets, "#6:" .. setflag .. "passwall_shunt6")
|
||||
domain_rules_str = domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")
|
||||
domain_rules_str = (not only_global and REMOTE_FAKEDNS == "1")
|
||||
and domain_rules_str
|
||||
or (domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ","))
|
||||
end
|
||||
table.insert(tmp_lines, domain_rules_str)
|
||||
insert_array_after(config_lines, tmp_lines, "#--3")
|
||||
|
Loading…
Reference in New Issue
Block a user