mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 21:23:04 +00:00
Fix
This commit is contained in:
parent
57ba378072
commit
7a978bf43d
4 changed files with 17 additions and 12 deletions
|
|
@ -462,6 +462,18 @@ public class Utils
|
|||
return (domain, port);
|
||||
}
|
||||
|
||||
public static string? DomainStrategy4Sbox(string? strategy)
|
||||
{
|
||||
return strategy switch
|
||||
{
|
||||
not null when strategy.StartsWith("UseIPv4") => "prefer_ipv4",
|
||||
not null when strategy.StartsWith("UseIPv6") => "prefer_ipv6",
|
||||
not null when strategy.StartsWith("ForceIPv4") => "ipv4_only",
|
||||
not null when strategy.StartsWith("ForceIPv6") => "ipv6_only",
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
#endregion Conversion Functions
|
||||
|
||||
#region Data Checks
|
||||
|
|
|
|||
|
|
@ -398,13 +398,6 @@ public class Global
|
|||
""
|
||||
];
|
||||
|
||||
public static readonly Dictionary<string, string> DomainStrategy4SboxMap =
|
||||
DomainStrategy
|
||||
.Where(s => s.StartsWith("UseIPv4", StringComparison.Ordinal) || s.StartsWith("UseIPv6", StringComparison.Ordinal))
|
||||
.ToDictionary(
|
||||
key => key,
|
||||
key => key.StartsWith("UseIPv4", StringComparison.Ordinal) ? "prefer_ipv4" : "prefer_ipv6");
|
||||
|
||||
public static readonly List<string> DomainDirectDNSAddress =
|
||||
[
|
||||
"https://dns.alidns.com/dns-query",
|
||||
|
|
|
|||
|
|
@ -180,13 +180,13 @@ public partial class CoreConfigSingboxService
|
|||
new Rule4Sbox
|
||||
{
|
||||
server = Global.SingboxRemoteDNSTag,
|
||||
strategy = Global.DomainStrategy4SboxMap.GetValueOrDefault(simpleDNSItem.Strategy4Proxy),
|
||||
strategy = Utils.DomainStrategy4Sbox(simpleDNSItem.Strategy4Proxy),
|
||||
clash_mode = ERuleMode.Global.ToString()
|
||||
},
|
||||
new Rule4Sbox
|
||||
{
|
||||
server = Global.SingboxDirectDNSTag,
|
||||
strategy = Global.DomainStrategy4SboxMap.GetValueOrDefault(simpleDNSItem.Strategy4Freedom),
|
||||
strategy = Utils.DomainStrategy4Sbox(simpleDNSItem.Strategy4Freedom),
|
||||
clash_mode = ERuleMode.Direct.ToString()
|
||||
}
|
||||
});
|
||||
|
|
@ -309,7 +309,7 @@ public partial class CoreConfigSingboxService
|
|||
if (item.OutboundTag == Global.DirectTag)
|
||||
{
|
||||
rule.server = Global.SingboxDirectDNSTag;
|
||||
rule.strategy = Global.DomainStrategy4SboxMap.GetValueOrDefault(simpleDNSItem.Strategy4Freedom);
|
||||
rule.strategy = Utils.DomainStrategy4Sbox(simpleDNSItem.Strategy4Freedom);
|
||||
|
||||
if (expectedIPsRegions.Count > 0 && rule.geosite?.Count > 0)
|
||||
{
|
||||
|
|
@ -343,7 +343,7 @@ public partial class CoreConfigSingboxService
|
|||
singboxConfig.dns.rules.Add(rule4Fake);
|
||||
}
|
||||
rule.server = Global.SingboxRemoteDNSTag;
|
||||
rule.strategy = Global.DomainStrategy4SboxMap.GetValueOrDefault(simpleDNSItem.Strategy4Proxy);
|
||||
rule.strategy = Utils.DomainStrategy4Sbox(simpleDNSItem.Strategy4Proxy);
|
||||
}
|
||||
|
||||
singboxConfig.dns.rules.Add(rule);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ public partial class CoreConfigSingboxService
|
|||
var simpleDnsItem = _config.SimpleDNSItem;
|
||||
|
||||
var defaultDomainResolverTag = Global.SingboxDirectDNSTag;
|
||||
var directDnsStrategy = Global.DomainStrategy4SboxMap.GetValueOrDefault(simpleDnsItem.Strategy4Freedom);
|
||||
var directDnsStrategy = Utils.DomainStrategy4Sbox(simpleDnsItem.Strategy4Freedom);
|
||||
|
||||
var rawDNSItem = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||
if (rawDNSItem is { Enabled: true })
|
||||
|
|
|
|||
Loading…
Reference in a new issue