mirror of https://github.com/2dust/v2rayN
Fix
parent
e43fb5be70
commit
4f560e86ab
|
@ -1402,7 +1402,7 @@
|
||||||
<value>直连 DNS</value>
|
<value>直连 DNS</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSBOutboundsResolverDNS" xml:space="preserve">
|
<data name="TbSBOutboundsResolverDNS" xml:space="preserve">
|
||||||
<value>出站 DNS 解析</value>
|
<value>出站 DNS 解析(sing-box)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSBOutboundDomainResolve" xml:space="preserve">
|
<data name="TbSBOutboundDomainResolve" xml:space="preserve">
|
||||||
<value>解析出站域名</value>
|
<value>解析出站域名</value>
|
||||||
|
|
|
@ -1603,7 +1603,20 @@ public class CoreConfigSingboxService
|
||||||
|
|
||||||
singboxConfig.dns ??= new Dns4Sbox();
|
singboxConfig.dns ??= new Dns4Sbox();
|
||||||
singboxConfig.dns.independent_cache = true;
|
singboxConfig.dns.independent_cache = true;
|
||||||
singboxConfig.dns.final = "dns_remote"; // TODO: Select fallback DNS server based on routing rules
|
|
||||||
|
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
||||||
|
var useDirectDns = false;
|
||||||
|
if (routing != null)
|
||||||
|
{
|
||||||
|
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet) ?? [];
|
||||||
|
|
||||||
|
useDirectDns = rules?.LastOrDefault() is { } lastRule &&
|
||||||
|
lastRule.OutboundTag == Global.DirectTag &&
|
||||||
|
(lastRule.Port == "0-65535" ||
|
||||||
|
lastRule.Network == "tcp,udp" ||
|
||||||
|
lastRule.Ip?.Contains("0.0.0.0/0") == true);
|
||||||
|
}
|
||||||
|
singboxConfig.dns.final = useDirectDns ? "dns_direct" : "dns_remote";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1232,9 +1232,10 @@ public class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
|
|
||||||
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
||||||
|
List<RulesItem>? rules = null;
|
||||||
if (routing != null)
|
if (routing != null)
|
||||||
{
|
{
|
||||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet) ?? [];
|
rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet) ?? [];
|
||||||
foreach (var item in rules)
|
foreach (var item in rules)
|
||||||
{
|
{
|
||||||
if (!item.Enabled || item.Domain is null || item.Domain.Count == 0)
|
if (!item.Enabled || item.Domain is null || item.Domain.Count == 0)
|
||||||
|
@ -1317,7 +1318,14 @@ public class CoreConfigV2rayService
|
||||||
AddDnsServers(directDNSAddress, directGeositeList);
|
AddDnsServers(directDNSAddress, directGeositeList);
|
||||||
AddDnsServers(directDNSAddress, expectedDomainList, expectedIPs);
|
AddDnsServers(directDNSAddress, expectedDomainList, expectedIPs);
|
||||||
|
|
||||||
v2rayConfig.dns.servers.AddRange(remoteDNSAddress);
|
var useDirectDns = rules?.LastOrDefault() is { } lastRule &&
|
||||||
|
lastRule.OutboundTag == Global.DirectTag &&
|
||||||
|
(lastRule.Port == "0-65535" ||
|
||||||
|
lastRule.Network == "tcp,udp" ||
|
||||||
|
lastRule.Ip?.Contains("0.0.0.0/0") == true);
|
||||||
|
|
||||||
|
var defaultDnsServers = useDirectDns ? directDNSAddress : remoteDNSAddress;
|
||||||
|
v2rayConfig.dns.servers.AddRange(defaultDnsServers);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue