diff --git a/v2rayN/ServiceLib.Tests/CoreConfig/V2ray/CoreConfigV2rayServiceTests.cs b/v2rayN/ServiceLib.Tests/CoreConfig/V2ray/CoreConfigV2rayServiceTests.cs index e8b08809..d083dcf9 100644 --- a/v2rayN/ServiceLib.Tests/CoreConfig/V2ray/CoreConfigV2rayServiceTests.cs +++ b/v2rayN/ServiceLib.Tests/CoreConfig/V2ray/CoreConfigV2rayServiceTests.cs @@ -2,6 +2,43 @@ namespace ServiceLib.Tests.CoreConfig.V2ray; public class CoreConfigV2rayServiceTests { + [Test] + [Arguments(null)] + [Arguments("")] + [Arguments("AGH+DQBdAAAgACBAi73MnT3WWXWj4M9MUiTygpjSPUfM/Rj3Iasve4uFQAAkAAEAAQABAAIAAQADAAIAAQACAAIAAgADAAMAAQADAAIAAwADAA5vdXRlci5lY2gudGVzdAAA")] + [Arguments("https://dns.example.com/dns-query")] + [Arguments("udp://127.0.0.1:5353")] + [Arguments("ech.example.com+https://dns.example.com/dns-query")] + public async Task GenerateClientConfigContent_Tls_ShouldPreserveEchConfigWithoutLegacyQueryOption(string? echConfigList) + { + var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray); + CoreConfigTestFactory.BindAppManagerConfig(config); + var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray); + node.StreamSecurity = Global.StreamSecurity; + node.Sni = "ech.example.com"; + node.EchConfigList = echConfigList; + var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray); + + var result = new CoreConfigV2rayService(context).GenerateClientConfigContent(); + + await result.Success.Should().BeTrue(); + var generatedConfig = JsonNode.Parse(result.Data!.ToString()!)!; + var proxy = generatedConfig["outbounds"]!.AsArray() + .First(outbound => outbound!["tag"]!.GetValue() == Global.ProxyTag)!; + var tls = proxy["streamSettings"]!["tlsSettings"]!.AsObject(); + + await tls["serverName"]!.GetValue().Should().BeEqualTo("ech.example.com"); + if (string.IsNullOrEmpty(echConfigList)) + { + await tls.ContainsKey("echConfigList").Should().BeFalse(); + } + else + { + await tls["echConfigList"]!.GetValue().Should().BeEqualTo(echConfigList); + } + await tls.ContainsKey("echForceQuery").Should().BeFalse(); + } + [Test] public async Task GenerateClientConfigContent_ShouldGenerateBasicProxyConfig() { diff --git a/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs b/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs index a56a3fe0..6a8411c4 100644 --- a/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/CoreConfigs/V2rayConfig.cs @@ -343,7 +343,6 @@ public class TlsSettings4Ray public string? pinnedPeerCertSha256 { get; set; } public bool? disableSystemRoot { get; set; } public string? echConfigList { get; set; } - public string? echForceQuery { get; set; } public Sockopt4Ray? echSockopt { get; set; } } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs index 964e560d..3426d6c8 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs @@ -337,11 +337,6 @@ public partial class CoreConfigV2rayService { tlsSettings.serverName = Utils.String2List(host)?.First(); } - if (!tlsSettings.echConfigList.IsNullOrEmpty()) - { - // For legacy xray compatibility, remove this in the future - tlsSettings.echForceQuery = "full"; - } var certs = CertPemManager.ParsePemChain(_node.Cert); if (certs.Count > 0) {