* Revert "feat(dns): expose Xray fallback restriction for matched domains (#10602)"

This reverts commit 917efefd5a.

* Fix dns
This commit is contained in:
DHR60
2026-11-16 11:16:07 +00:00
committed by GitHub
parent 917efefd5a
commit ba3a31aa85
13 changed files with 37 additions and 343 deletions
@@ -2,98 +2,6 @@ namespace ServiceLib.Tests.CoreConfig.V2ray;
public class CoreConfigV2rayServiceTests public class CoreConfigV2rayServiceTests
{ {
[Test]
[Arguments(false, "0-65535", null, Global.ProxyTag)]
[Arguments(false, "1-65535", null, Global.ProxyTag)]
[Arguments(true, "0-65535", null, Global.ProxyTag)]
[Arguments(true, null, "tcp,udp", Global.ProxyTag)]
[Arguments(false, null, null, Global.ProxyTag)]
[Arguments(false, "0-65535", null, Global.BlockTag)]
public async Task DirectDnsRule_ShouldPrecedeCatchAllAndPreserveExplicitRules(bool tun, string? port, string? network, string outbound)
{
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
config.TunModeItem.EnableTun = tun;
config.SimpleDNSItem.DirectDNS = "8.8.8.8";
config.SimpleDNSItem.RemoteDNS = "1.1.1.1";
CoreConfigTestFactory.BindAppManagerConfig(config);
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray);
var userRules = new List<RulesItem>
{
new() { RuleType = ERuleType.DNS, Domain = ["domain:direct.example"], OutboundTag = Global.DirectTag },
new() { InboundTag = ["direct-dns-1"], Ip = ["8.8.8.8"], Port = "53", OutboundTag = Global.BlockTag },
new() { Port = "443", Network = "tcp", OutboundTag = Global.ProxyTag },
};
if (port != null || network != null)
{
userRules.Add(new() { Port = port, Network = network, OutboundTag = outbound });
}
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
{
RoutingItem = new RoutingItem { RuleSet = JsonUtils.Serialize(userRules), DomainStrategy = Global.IPOnDemand }
};
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
await result.Success.Should().BeTrue();
var rules = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!.routing.rules;
var direct = rules.FindIndex(r => r.outboundTag == Global.DirectTag && r.inboundTag?.Contains("direct-dns-1") == true);
var explicitBlock = rules.FindIndex(r => r.outboundTag == Global.BlockTag && r.inboundTag?.Contains("direct-dns-1") == true);
var https = rules.FindIndex(r => r.port == "443" && r.network == "tcp" && r.outboundTag == Global.ProxyTag);
await (explicitBlock >= 0 && https > explicitBlock && direct > https).Should().BeTrue();
if (port != null || network != null)
{
var catchAll = rules.FindIndex(r => r.port == port && r.network == network && r.inboundTag == null && r.outboundTag == outbound);
await (catchAll >= 0 && (outbound == Global.ProxyTag ? catchAll > direct : catchAll < direct)).Should().BeTrue();
}
if (tun)
{
var intercept = rules.FindIndex(r => r.inboundTag?.Contains("tun") == true && r.port == "53" && r.outboundTag == Global.DnsOutboundTag);
await (intercept >= 0 && intercept < direct).Should().BeTrue();
}
await rules.Should().Contain(r => r.inboundTag != null && r.inboundTag.Contains(Global.DnsTag) && r.outboundTag == Global.ProxyTag);
}
[Test]
[Arguments("0-65535", null)]
[Arguments("1-65535", null)]
[Arguments(null, "udp,tcp")]
public async Task DirectDnsRule_ShouldPrecedeCatchAllBalancer(string? port, string? network)
{
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
config.SimpleDNSItem.DirectDNS = "8.8.8.8,https://8.8.4.4/dns-query";
config.SimpleDNSItem.RemoteDNS = "1.1.1.1";
CoreConfigTestFactory.BindAppManagerConfig(config);
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n1", "node-1");
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n2", "node-2");
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, "g1", "group", [n1.IndexId, n2.IndexId]);
var context = CoreConfigTestFactory.CreateContext(config, group, ECoreType.Xray) with
{
RoutingItem = new RoutingItem
{
RuleSet = JsonUtils.Serialize(new List<RulesItem>
{
new() { RuleType = ERuleType.DNS, Domain = ["domain:direct.example"], OutboundTag = Global.DirectTag },
new() { Port = port, Network = network, OutboundTag = Global.ProxyTag },
}),
DomainStrategy = Global.AsIs,
},
};
context.AllProxiesMap[n1.IndexId] = n1;
context.AllProxiesMap[n2.IndexId] = n2;
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
await result.Success.Should().BeTrue();
var rules = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!.routing.rules;
var direct = rules.FindIndex(r => r.outboundTag == Global.DirectTag && r.inboundTag?.Contains("direct-dns-1") == true);
var catchAll = rules.FindIndex(r => r.port == port && r.network == network && r.inboundTag == null
&& r.balancerTag == Global.ProxyTag + Global.BalancerTagSuffix);
await (direct >= 0 && catchAll > direct).Should().BeTrue();
await rules[direct].inboundTag.Should().Contain("direct-dns-2");
await rules.Should().Contain(r => r.inboundTag != null && r.inboundTag.Contains(Global.DnsTag)
&& r.balancerTag == Global.ProxyTag + Global.BalancerTagSuffix);
}
[Test] [Test]
[Arguments("demo-seed", "srtp", 2)] [Arguments("demo-seed", "srtp", 2)]
[Arguments(null, "srtp", 2)] [Arguments(null, "srtp", 2)]
@@ -1,107 +0,0 @@
namespace ServiceLib.Tests.CoreConfig.V2ray;
public class DnsFallbackTests
{
[Test]
[Arguments(null, false, false)]
[Arguments(false, false, false)]
[Arguments(true, false, false)]
[Arguments(null, true, false)]
[Arguments(false, true, false)]
[Arguments(true, true, false)]
[Arguments(null, false, true)]
[Arguments(false, false, true)]
[Arguments(true, false, true)]
[Arguments(null, true, true)]
[Arguments(false, true, true)]
[Arguments(true, true, true)]
public async Task SimpleDns_ShouldPersistAndApplyFallbackChoice(bool? disabled, bool parallel, bool tun)
{
var config = CoreConfigTestFactory.CreateConfig();
config.SimpleDNSItem.DisableFallbackIfMatch = disabled;
config.SimpleDNSItem.ParallelQuery = parallel;
config.SimpleDNSItem.DirectDNS = "8.8.8.8,8.8.4.4";
config.SimpleDNSItem.RemoteDNS = "1.1.1.1";
config.TunModeItem.EnableTun = tun;
config = JsonUtils.Deserialize<Config>(JsonUtils.Serialize(config))!;
await config.SimpleDNSItem.DisableFallbackIfMatch.Should().BeEqualTo(disabled);
CoreConfigTestFactory.BindAppManagerConfig(config);
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray);
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
{
RoutingItem = new RoutingItem
{
DomainStrategy = Global.AsIs,
RuleSet = JsonUtils.Serialize(new List<RulesItem>
{
new() { RuleType = ERuleType.DNS, Domain = ["domain:direct.example"], OutboundTag = Global.DirectTag },
}),
},
};
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
await result.Success.Should().BeTrue();
var dns = JsonNode.Parse(result.Data!.ToString()!)!["dns"]!;
await (dns["disableFallbackIfMatch"]?.GetValue<bool>()).Should().BeEqualTo(disabled == true ? true : (bool?)null);
await (dns["enableParallelQuery"]?.GetValue<bool>() == true).Should().BeEqualTo(parallel);
var servers = dns["servers"]!.AsArray();
var matched = servers.OfType<JsonObject>().Where(s => s["domains"] != null).ToList();
await matched.Count.Should().BeEqualTo(2);
await matched.All(s => s["skipFallback"]!.GetValue<bool>()).Should().BeTrue();
await servers.Last()!.GetValue<string>().Should().BeEqualTo("1.1.1.1");
}
[Test]
[Arguments(false, true, false)]
[Arguments(true, false, false)]
[Arguments(false, true, true)]
[Arguments(true, false, true)]
public async Task RawDns_ShouldUseItsOwnFallbackChoice(bool simpleChoice, bool rawChoice, bool tun)
{
var config = CoreConfigTestFactory.CreateConfig();
config.SimpleDNSItem.DisableFallbackIfMatch = simpleChoice;
config.TunModeItem.EnableTun = tun;
CoreConfigTestFactory.BindAppManagerConfig(config);
var raw = new JsonObject
{
["servers"] = new JsonArray("1.1.1.1"),
["disableFallbackIfMatch"] = rawChoice,
}.ToJsonString();
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray);
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
{
RawDnsItem = new DNSItem { Enabled = true, NormalDNS = raw, TunDNS = raw },
};
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
await result.Success.Should().BeTrue();
var dns = JsonNode.Parse(result.Data!.ToString()!)!["dns"]!;
await dns["disableFallbackIfMatch"]!.GetValue<bool>().Should().BeEqualTo(rawChoice);
}
[Test]
public async Task ExistingSettings_ShouldKeepFallbackEnabledByDefault()
{
var simple = JsonUtils.Deserialize<SimpleDNSItem>("{\"DirectDNS\":\"8.8.8.8\",\"RemoteDNS\":\"1.1.1.1\"}")!;
await simple.DisableFallbackIfMatch.Should().BeNull();
}
[Test]
public async Task Singbox_ShouldGenerateTheSameDnsForBothFallbackChoices()
{
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
CoreConfigTestFactory.BindAppManagerConfig(config);
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box);
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box);
var before = new CoreConfigSingboxService(context).GenerateClientConfigContent();
config.SimpleDNSItem.DisableFallbackIfMatch = true;
var after = new CoreConfigSingboxService(context).GenerateClientConfigContent();
await before.Success.Should().BeTrue();
await after.Success.Should().BeTrue();
await JsonNode.DeepEquals(JsonNode.Parse(before.Data!.ToString()!)!["dns"],
JsonNode.Parse(after.Data!.ToString()!)!["dns"]).Should().BeTrue();
}
}
@@ -268,7 +268,6 @@ public class SimpleDNSItem
public string? Strategy4ProxyDial { get; set; } public string? Strategy4ProxyDial { get; set; }
public bool? ServeStale { get; set; } public bool? ServeStale { get; set; }
public bool? ParallelQuery { get; set; } public bool? ParallelQuery { get; set; }
public bool? DisableFallbackIfMatch { get; set; }
public string? Hosts { get; set; } public string? Hosts { get; set; }
public string? DirectExpectedIPs { get; set; } public string? DirectExpectedIPs { get; set; }
public bool? EnableHappyEyeballs { get; set; } public bool? EnableHappyEyeballs { get; set; }
-18
View File
@@ -3636,24 +3636,6 @@ namespace ServiceLib.Resx {
} }
} }
/// <summary>
/// Looks up the localized DNS fallback setting label.
/// </summary>
public static string TbDisableFallbackIfMatch {
get {
return ResourceManager.GetString("TbDisableFallbackIfMatch", resourceCulture);
}
}
/// <summary>
/// Looks up the localized DNS fallback setting explanation.
/// </summary>
public static string TbDisableFallbackIfMatchTip {
get {
return ResourceManager.GetString("TbDisableFallbackIfMatchTip", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Parallel Query 的本地化字符串。 /// 查找类似 Parallel Query 的本地化字符串。
/// </summary> /// </summary>
-6
View File
@@ -1974,10 +1974,4 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
<data name="TransportPathTip6" xml:space="preserve"> <data name="TransportPathTip6" xml:space="preserve">
<value>XDRIVE remote folder</value> <value>XDRIVE remote folder</value>
</data> </data>
<data name="TbDisableFallbackIfMatch" xml:space="preserve">
<value>Restrict DNS fallback on domain match (Xray)</value>
</data>
<data name="TbDisableFallbackIfMatchTip" xml:space="preserve">
<value>Use only DNS servers with matching domain rules, including bootstrap. If all fail, resolution fails. Other domains use the default DNS servers.</value>
</data>
</root> </root>
-6
View File
@@ -1974,10 +1974,4 @@
<data name="TransportPathTip6" xml:space="preserve"> <data name="TransportPathTip6" xml:space="preserve">
<value>Удаленная папка XDRIVE</value> <value>Удаленная папка XDRIVE</value>
</data> </data>
<data name="TbDisableFallbackIfMatch" xml:space="preserve">
<value>Ограничить резервные DNS при совпадении домена (Xray)</value>
</data>
<data name="TbDisableFallbackIfMatchTip" xml:space="preserve">
<value>Только DNS с совпавшими доменными правилами, включая bootstrap. Если все они не сработают, разрешение завершится ошибкой. Для остальных доменов — DNS по умолчанию.</value>
</data>
</root> </root>
@@ -1966,10 +1966,4 @@
<data name="TransportPathTip6" xml:space="preserve"> <data name="TransportPathTip6" xml:space="preserve">
<value>XDRIVE 远端目录</value> <value>XDRIVE 远端目录</value>
</data> </data>
<data name="TbDisableFallbackIfMatch" xml:space="preserve">
<value>域名匹配时限制 DNS 回退(Xray)</value>
</data>
<data name="TbDisableFallbackIfMatchTip" xml:space="preserve">
<value>仅使用域名规则匹配的 DNS(包括引导 DNS)。若全部失败,解析失败。其他域名使用默认 DNS。</value>
</data>
</root> </root>
@@ -79,9 +79,9 @@ public partial class CoreConfigV2rayService
FillDnsServers(dnsItem); FillDnsServers(dnsItem);
FillDnsHosts(dnsItem); FillDnsHosts(dnsItem);
dnsItem.disableFallbackIfMatch = true;
dnsItem.serveStale = simpleDnsItem?.ServeStale is true ? true : null; dnsItem.serveStale = simpleDnsItem?.ServeStale is true ? true : null;
dnsItem.enableParallelQuery = simpleDnsItem?.ParallelQuery is true ? true : null; dnsItem.enableParallelQuery = simpleDnsItem?.ParallelQuery is true ? true : null;
dnsItem.disableFallbackIfMatch = simpleDnsItem?.DisableFallbackIfMatch is true ? true : null;
if (simpleDnsItem.BlockAAAAQuery == true) if (simpleDnsItem.BlockAAAAQuery == true)
{ {
@@ -89,26 +89,12 @@ public partial class CoreConfigV2rayService
} }
// DNS routing // DNS routing
var directDnsTags = dnsItem.servers _coreConfig.routing.rules.Insert(0, new()
.Select(server =>
{
var tagNode = (server as JsonObject)?["tag"];
return tagNode is JsonValue value && value.TryGetValue<string>(out var tag) ? tag : null;
})
.Where(tag => tag is not null && tag.StartsWith(Global.DirectDnsTag, StringComparison.Ordinal))
.Select(tag => tag!)
.ToList();
if (directDnsTags.Count > 0)
{ {
var rules = _coreConfig.routing.rules; type = "field",
var catchAllIndex = rules.FindIndex(IsDnsRoutingCatchAll); inboundTag = [Global.DirectDnsTag],
rules.Insert(catchAllIndex < 0 ? rules.Count : catchAllIndex, new() outboundTag = Global.DirectTag,
{ });
type = "field",
inboundTag = directDnsTags,
outboundTag = Global.DirectTag,
});
}
var finalRule = BuildFinalRule(); var finalRule = BuildFinalRule();
dnsItem.tag = Global.DnsTag; dnsItem.tag = Global.DnsTag;
@@ -128,16 +114,28 @@ public partial class CoreConfigV2rayService
} }
} }
private static bool IsDnsRoutingCatchAll(RulesItem4Ray rule) private static bool IsCatchAllRule(RulesItem rule)
{ {
return (rule.outboundTag == Global.ProxyTag || rule.balancerTag == Global.ProxyTag + Global.BalancerTagSuffix) if (!rule.Enabled)
&& rule.inboundTag is not { Count: > 0 } {
&& rule.domain is not { Count: > 0 } return false;
&& rule.ip is not { Count: > 0 } }
&& rule.protocol is not { Count: > 0 }
&& rule.process is not { Count: > 0 } var hasNoFilters = rule.InboundTag is not { Count: > 0 }
&& rule.port is null or "0-65535" or "1-65535" && rule.Domain is not { Count: > 0 }
&& rule.network is null or "tcp,udp" or "udp,tcp"; && rule.Protocol is not { Count: > 0 }
&& rule.Process is not { Count: > 0 };
var isWildcardIp = rule.Ip is null
|| rule.Ip.Count == 0
|| rule.Ip.Contains("0.0.0.0/0")
|| rule.Ip.Contains("::/0");
var isWildcardPort = string.IsNullOrEmpty(rule.Port) || rule.Port is "0-65535" or "1-65535";
var isWildcardNetwork = string.IsNullOrEmpty(rule.Network) || rule.Network is "tcp,udp" or "udp,tcp";
return hasNoFilters && isWildcardIp && isWildcardPort && isWildcardNetwork;
} }
private void GenFakeDns() private void GenFakeDns()
@@ -240,8 +238,8 @@ public partial class CoreConfigV2rayService
} }
var routing = context.RoutingItem; var routing = context.RoutingItem;
List<RulesItem>? rules = null; var rules = JsonUtils.Deserialize<List<RulesItem>>(routing?.RuleSet) ?? [];
rules = JsonUtils.Deserialize<List<RulesItem>>(routing?.RuleSet) ?? []; var useDirectDns = rules.Where(IsCatchAllRule).Any(r => r.OutboundTag == Global.DirectTag);
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)
@@ -295,8 +293,6 @@ public partial class CoreConfigV2rayService
dnsItem.servers ??= []; dnsItem.servers ??= [];
var directDnsTagIndex = 1;
if (dnsServerDomains.Count > 0) if (dnsServerDomains.Count > 0)
{ {
AddDnsServers(bootstrapDNSAddress, dnsServerDomains); AddDnsServers(bootstrapDNSAddress, dnsServerDomains);
@@ -327,30 +323,19 @@ public partial class CoreConfigV2rayService
AddDnsServers(directDNSAddress, directDomainList, true); AddDnsServers(directDNSAddress, directDomainList, true);
AddDnsServers(remoteDNSAddress, proxyGeositeList); AddDnsServers(remoteDNSAddress, proxyGeositeList);
AddDnsServers(directDNSAddress, directGeositeList, true); AddDnsServers(directDNSAddress, directGeositeList, true);
AddDnsServers(directDNSAddress, expectedDomainList, true, expectedIPs); AddDnsServers(directDNSAddress, expectedDomainList, true, expectedIPs, false);
AddDnsServers(remoteDNSAddress, expectedDomainList, false, expectedIPs);
var useDirectDns = false;
if (rules?.LastOrDefault() is { OutboundTag: Global.DirectTag } lastRule)
{
var noDomain = lastRule.Domain == null || lastRule.Domain.Count == 0;
var noProcess = lastRule.Process == null || lastRule.Process.Count == 0;
var isAnyIp = lastRule.Ip == null || lastRule.Ip.Count == 0 || lastRule.Ip.Contains("0.0.0.0/0");
var isAnyPort = string.IsNullOrEmpty(lastRule.Port) || lastRule.Port == "0-65535";
var isAnyNetwork = string.IsNullOrEmpty(lastRule.Network) || lastRule.Network == "tcp,udp";
useDirectDns = noDomain && noProcess && isAnyIp && isAnyPort && isAnyNetwork;
}
if (!useDirectDns) if (!useDirectDns)
{ {
dnsItem.servers.AddRange(JsonUtils.SerializeToArray(remoteDNSAddress)); dnsItem.servers.AddRange(JsonUtils.SerializeToArray(remoteDNSAddress)!);
} }
else else
{ {
foreach (var dns in directDNSAddress) foreach (var dns in directDNSAddress)
{ {
var dnsServer = CreateDnsServer(dns, []); var dnsServer = CreateDnsServer(dns, []);
dnsServer.tag = $"{Global.DirectDnsTag}-{directDnsTagIndex++}"; dnsServer.tag = Global.DirectDnsTag;
dnsServer.skipFallback = false; dnsServer.skipFallback = false;
dnsItem.servers.Add(JsonUtils.SerializeToNode(dnsServer)); dnsItem.servers.Add(JsonUtils.SerializeToNode(dnsServer));
} }
@@ -394,7 +379,7 @@ public partial class CoreConfigV2rayService
return dnsServer; return dnsServer;
} }
void AddDnsServers(List<string> dnsAddresses, HashSet<string> domains, bool isDirectDns = false, HashSet<string>? expectedIPs = null) void AddDnsServers(List<string> dnsAddresses, HashSet<string> domains, bool isDirectDns = false, HashSet<string>? expectedIPs = null, bool finalQuery = true)
{ {
if (domains.Count <= 0) if (domains.Count <= 0)
{ {
@@ -407,10 +392,9 @@ public partial class CoreConfigV2rayService
var dnsServer = CreateDnsServer(dnsAddress, domains, expectedIPs); var dnsServer = CreateDnsServer(dnsAddress, domains, expectedIPs);
if (isDirectDns) if (isDirectDns)
{ {
dnsServer.tag = $"{Global.DirectDnsTag}-{directDnsTagIndex++}"; dnsServer.tag = Global.DirectDnsTag;
} }
if (expectedIPs is not null if (finalQuery && i == dnsAddresses.Count - 1)
&& i == expectedIPs.Count - 1)
{ {
dnsServer.finalQuery = true; dnsServer.finalQuery = true;
} }
@@ -23,7 +23,6 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
[Reactive] public partial string Hosts { get; set; } [Reactive] public partial string Hosts { get; set; }
[Reactive] public partial string DirectExpectedIPs { get; set; } [Reactive] public partial string DirectExpectedIPs { get; set; }
[Reactive] public partial bool ParallelQuery { get; set; } [Reactive] public partial bool ParallelQuery { get; set; }
[Reactive] public partial bool DisableFallbackIfMatch { get; set; }
[Reactive] public partial bool ServeStale { get; set; } [Reactive] public partial bool ServeStale { get; set; }
[Reactive] public partial bool EnableHappyEyeballs { get; set; } [Reactive] public partial bool EnableHappyEyeballs { get; set; }
@@ -102,7 +101,6 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
Hosts = item.Hosts ?? string.Empty; Hosts = item.Hosts ?? string.Empty;
DirectExpectedIPs = item.DirectExpectedIPs ?? string.Empty; DirectExpectedIPs = item.DirectExpectedIPs ?? string.Empty;
ParallelQuery = item.ParallelQuery ?? false; ParallelQuery = item.ParallelQuery ?? false;
DisableFallbackIfMatch = item.DisableFallbackIfMatch ?? false;
ServeStale = item.ServeStale ?? false; ServeStale = item.ServeStale ?? false;
EnableHappyEyeballs = item.EnableHappyEyeballs ?? false; EnableHappyEyeballs = item.EnableHappyEyeballs ?? false;
var item1 = await ConfigDbQuery.GetDNSItem(ECoreType.Xray); var item1 = await ConfigDbQuery.GetDNSItem(ECoreType.Xray);
@@ -147,7 +145,6 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
_config.SimpleDNSItem.Hosts = Hosts; _config.SimpleDNSItem.Hosts = Hosts;
_config.SimpleDNSItem.DirectExpectedIPs = DirectExpectedIPs; _config.SimpleDNSItem.DirectExpectedIPs = DirectExpectedIPs;
_config.SimpleDNSItem.ParallelQuery = ParallelQuery; _config.SimpleDNSItem.ParallelQuery = ParallelQuery;
_config.SimpleDNSItem.DisableFallbackIfMatch = DisableFallbackIfMatch;
_config.SimpleDNSItem.ServeStale = ServeStale; _config.SimpleDNSItem.ServeStale = ServeStale;
_config.SimpleDNSItem.EnableHappyEyeballs = EnableHappyEyeballs; _config.SimpleDNSItem.EnableHappyEyeballs = EnableHappyEyeballs;
if (NormalDNSCompatible.IsNotEmpty()) if (NormalDNSCompatible.IsNotEmpty())
@@ -42,7 +42,7 @@
x:Name="gridBasicDNSSettings" x:Name="gridBasicDNSSettings"
Margin="{StaticResource Margin8}" Margin="{StaticResource Margin8}"
ColumnDefinitions="Auto,Auto,*" ColumnDefinitions="Auto,Auto,*"
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"> RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<TextBlock <TextBlock
x:Name="txtBasicDNSSettingsInvalid" x:Name="txtBasicDNSSettingsInvalid"
@@ -232,29 +232,6 @@
VerticalAlignment="Center" VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbEnableHappyEyeballsTip}" Text="{x:Static resx:ResUI.TbEnableHappyEyeballsTip}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<TextBlock
Grid.Row="11"
Grid.Column="0"
MaxWidth="260"
HorizontalAlignment="Left"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbDisableFallbackIfMatch}"
TextWrapping="Wrap" />
<ToggleSwitch
x:Name="togDisableFallbackIfMatch"
Grid.Row="11"
Grid.Column="1"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
<TextBlock
Grid.Row="11"
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbDisableFallbackIfMatchTip}"
TextWrapping="Wrap" />
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</TabItem> </TabItem>
@@ -49,8 +49,6 @@ public partial class DNSSettingWindow : WindowBase<DNSSettingViewModel>
this.Bind(ViewModel, vm => vm.Hosts, v => v.txtHosts.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Hosts, v => v.txtHosts.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.DirectExpectedIPs, v => v.cmbDirectExpectedIPs.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.DirectExpectedIPs, v => v.cmbDirectExpectedIPs.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.ParallelQuery, v => v.togParallelQuery.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.ParallelQuery, v => v.togParallelQuery.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.DisableFallbackIfMatch, v => v.togDisableFallbackIfMatch.IsChecked).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.RayCustomDNSEnableCompatible, v => v.togDisableFallbackIfMatch.IsEnabled, enabled => !enabled).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.ServeStale, v => v.togServeStale.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.ServeStale, v => v.togServeStale.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableHappyEyeballs, v => v.togEnableHappyEyeballs.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableHappyEyeballs, v => v.togEnableHappyEyeballs.IsChecked).DisposeWith(disposables);
-24
View File
@@ -54,7 +54,6 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@@ -265,29 +264,6 @@
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbEnableHappyEyeballsTip}" Text="{x:Static resx:ResUI.TbEnableHappyEyeballsTip}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<TextBlock
Grid.Row="11"
Grid.Column="0"
MaxWidth="260"
HorizontalAlignment="Left"
Margin="{StaticResource Margin8}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbDisableFallbackIfMatch}"
TextWrapping="Wrap" />
<ToggleButton
x:Name="togDisableFallbackIfMatch"
Grid.Row="11"
Grid.Column="1"
Margin="{StaticResource Margin8}"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
<TextBlock
Grid.Row="11"
Grid.Column="2"
Margin="{StaticResource Margin8}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbDisableFallbackIfMatchTip}"
TextWrapping="Wrap" />
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</TabItem> </TabItem>
@@ -45,8 +45,6 @@ public partial class DNSSettingWindow
this.Bind(ViewModel, vm => vm.Hosts, v => v.txtHosts.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Hosts, v => v.txtHosts.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.DirectExpectedIPs, v => v.cmbDirectExpectedIPs.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.DirectExpectedIPs, v => v.cmbDirectExpectedIPs.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.ParallelQuery, v => v.togParallelQuery.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.ParallelQuery, v => v.togParallelQuery.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.DisableFallbackIfMatch, v => v.togDisableFallbackIfMatch.IsChecked).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.RayCustomDNSEnableCompatible, v => v.togDisableFallbackIfMatch.IsEnabled, enabled => !enabled).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.ServeStale, v => v.togServeStale.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.ServeStale, v => v.togServeStale.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableHappyEyeballs, v => v.togEnableHappyEyeballs.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableHappyEyeballs, v => v.togEnableHappyEyeballs.IsChecked).DisposeWith(disposables);