From 588e82f0d940bb4c97416569decb404ec359a05d Mon Sep 17 00:00:00 2001 From: DHR60 Date: Tue, 10 Mar 2026 01:16:16 +0000 Subject: [PATCH] Tun ech protect (#8915) --- v2rayN/ServiceLib/Models/V2rayConfig.cs | 1 + .../CoreConfig/V2ray/CoreConfigV2rayService.cs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/v2rayN/ServiceLib/Models/V2rayConfig.cs b/v2rayN/ServiceLib/Models/V2rayConfig.cs index 2393d5fb..6d4eabcb 100644 --- a/v2rayN/ServiceLib/Models/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/V2rayConfig.cs @@ -360,6 +360,7 @@ public class TlsSettings4Ray public bool? disableSystemRoot { get; set; } public string? echConfigList { get; set; } public string? echForceQuery { get; set; } + public Sockopt4Ray? echSockopt { get; set; } } public class CertificateSettings4Ray diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/CoreConfigV2rayService.cs index ca8eeb0d..ad122243 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/CoreConfigV2rayService.cs @@ -316,12 +316,20 @@ public partial class CoreConfigV2rayService(CoreConfigContext context) SsMethod = Global.None, }); - foreach (var outbound in _coreConfig.outbounds.Where(outbound => outbound.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true)) + foreach (var outbound in _coreConfig.outbounds + .Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true)) { - outbound.streamSettings ??= new StreamSettings4Ray(); - outbound.streamSettings.sockopt ??= new Sockopt4Ray(); + outbound.streamSettings ??= new(); + outbound.streamSettings.sockopt ??= new(); outbound.streamSettings.sockopt.dialerProxy = "tun-project-ss"; } + // ech protected + foreach (var outbound in _coreConfig.outbounds + .Where(outbound => outbound.streamSettings?.tlsSettings?.echConfigList?.IsNullOrEmpty() == false)) + { + outbound.streamSettings!.tlsSettings!.echSockopt ??= new(); + outbound.streamSettings.tlsSettings.echSockopt.dialerProxy = "tun-project-ss"; + } _coreConfig.outbounds.Add(new CoreConfigV2rayService(context with { Node = protectNode,