luci: update chinadns-ng logic

Follow the new feature upgrade.
This commit is contained in:
xiaorouji 2023-04-21 13:45:38 +08:00 committed by sbwml
parent cae9a39230
commit 61b45025ca
2 changed files with 21 additions and 16 deletions

View File

@ -423,7 +423,7 @@ run_chinadns_ng() {
([ -n "$_chnlist" ] || [ -n "$_gfwlist" ]) && [ -s "${RULES_PATH}/gfwlist" ] && { ([ -n "$_chnlist" ] || [ -n "$_gfwlist" ]) && [ -s "${RULES_PATH}/gfwlist" ] && {
local _gfwlist_file="${TMP_PATH}/chinadns_gfwlist" local _gfwlist_file="${TMP_PATH}/chinadns_gfwlist"
cp -a "${RULES_PATH}/gfwlist" "${_gfwlist_file}" cp -a "${RULES_PATH}/gfwlist" "${_gfwlist_file}"
_extra_param="${_extra_param} -g ${_gfwlist_file}" _extra_param="${_extra_param} -g ${_gfwlist_file} -A gfwlist,gfwlist6"
#当只有使用gfwlist模式时设置默认DNS为本地直连 #当只有使用gfwlist模式时设置默认DNS为本地直连
[ -n "$_gfwlist" ] && [ -z "$_chnlist" ] && _default_tag="chn" [ -n "$_gfwlist" ] && [ -z "$_chnlist" ] && _default_tag="chn"
} }

View File

@ -291,24 +291,29 @@ if not fs.access(CACHE_DNS_PATH) then
--如果没有使用回国模式 --如果没有使用回国模式
if not returnhome then if not returnhome then
if fs.access("/usr/share/passwall/rules/gfwlist") then if fs.access("/usr/share/passwall/rules/gfwlist") then
local gfwlist_str = sys.exec('cat /usr/share/passwall/rules/gfwlist | grep -v -E "^#" | grep -v -E "' .. excluded_domain_str .. '"') fwd_dns = TUN_DNS
for line in string.gmatch(gfwlist_str, "[^\r\n]+") do if CHNROUTE_MODE_DEFAULT_DNS == "chinadns_ng" and CHINADNS_DNS ~= "0" then
if line ~= "" then fwd_dns = nil
local ipset_flag = setflag_4 .. "gfwlist," .. setflag_6 .. "gfwlist6" else
if NO_PROXY_IPV6 == "1" then local ipset_flag = setflag_4 .. "gfwlist," .. setflag_6 .. "gfwlist6"
ipset_flag = setflag_4 .. "gfwlist" if NO_PROXY_IPV6 == "1" then
set_domain_address(line, "::") ipset_flag = setflag_4 .. "gfwlist"
end
if not only_global then
if REMOTE_FAKEDNS == "1" then
ipset_flag = nil
end end
if not only_global then end
fwd_dns = TUN_DNS local gfwlist_str = sys.exec('cat /usr/share/passwall/rules/gfwlist | grep -v -E "^#" | grep -v -E "' .. excluded_domain_str .. '"')
if CHNROUTE_MODE_DEFAULT_DNS == "chinadns_ng" and CHINADNS_DNS ~= "0" then for line in string.gmatch(gfwlist_str, "[^\r\n]+") do
fwd_dns = nil if line ~= "" then
if NO_PROXY_IPV6 == "1" then
set_domain_address(line, "::")
end end
if REMOTE_FAKEDNS == "1" then if not only_global then
ipset_flag = nil set_domain_dns(line, fwd_dns)
set_domain_ipset(line, ipset_flag)
end end
set_domain_dns(line, fwd_dns)
set_domain_ipset(line, ipset_flag)
end end
end end
end end