diff --git a/luci-app-passwall/luasrc/passwall/util_sing-box.lua b/luci-app-passwall/luasrc/passwall/util_sing-box.lua index a411e0a8d..38cb7bc9a 100644 --- a/luci-app-passwall/luasrc/passwall/util_sing-box.lua +++ b/luci-app-passwall/luasrc/passwall/util_sing-box.lua @@ -130,13 +130,10 @@ function gen_outbound(flag, node, tag, proxy_table) if version_ge_1_12_0 then --https://sing-box.sagernet.org/migration/#migrate-outbound-domain-strategy-option-to-domain-resolver result.domain_strategy = nil - if node.domain_strategy then - local domain_resolver = { - server = "direct", - strategy = node.domain_strategy - } - result.domain_resolver = domain_resolver - end + result.domain_resolver = { + server = "direct", + strategy = (node.domain_strategy and node.domain_strategy ~="") and node.domain_strategy or nil + } end local tls = nil @@ -1762,6 +1759,23 @@ function gen_config(var) strategy = "prefer_ipv6" } direct_outbound.domain_resolver = domain_resolver + -- 当没有 direct dns 服务器时添加 local + if config.dns and config.dns.servers then + for _, server in ipairs(config.dns.servers) do + if server.tag == "direct" then + break + end + end + else + config.dns = { + servers = { + { + type = "local", + tag = "direct" + } + }, + } + end end table.insert(outbounds,direct_outbound)