From e0402a03cd5e628ad568a135f3646a5546305084 Mon Sep 17 00:00:00 2001 From: DHR60 Date: Sat, 31 Jan 2026 22:43:04 +0800 Subject: [PATCH 1/2] Add xray v26.1.31 hysteria2 support --- v2rayN/ServiceLib/Models/V2rayConfig.cs | 16 +++++++++++----- .../CoreConfig/V2ray/V2rayOutboundService.cs | 11 +++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/v2rayN/ServiceLib/Models/V2rayConfig.cs b/v2rayN/ServiceLib/Models/V2rayConfig.cs index d9575432..90084b8f 100644 --- a/v2rayN/ServiceLib/Models/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/V2rayConfig.cs @@ -343,7 +343,7 @@ public class StreamSettings4Ray public HysteriaSettings4Ray? hysteriaSettings { get; set; } - public List? udpmasks { get; set; } + public FinalMask4Ray? finalmask { get; set; } public Sockopt4Ray? sockopt { get; set; } } @@ -484,13 +484,19 @@ public class HysteriaUdpHop4Ray public int? interval { get; set; } } -public class UdpMasks4Ray +public class FinalMask4Ray { - public string type { get; set; } - public UdpMasksSettings4Ray? settings { get; set; } + public List? tcp { get; set; } + public List? udp { get; set; } } -public class UdpMasksSettings4Ray +public class Mask4Ray +{ + public string type { get; set; } + public MaskSettings4Ray? settings { get; set; } +} + +public class MaskSettings4Ray { public string? password { get; set; } } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs index 3db5a420..71d3ef6c 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs @@ -512,8 +512,15 @@ public partial class CoreConfigV2rayService streamSettings.hysteriaSettings = hysteriaSettings; if (node.Path.IsNotEmpty()) { - streamSettings.udpmasks = - [new() { type = "salamander", settings = new() { password = node.Path.TrimEx(), } }]; + streamSettings.finalmask ??= new(); + streamSettings.finalmask.udp = + [ + new Mask4Ray + { + type = "salamander", + settings = new MaskSettings4Ray { password = node.Path.TrimEx(), } + } + ]; } break; From 2a1063495717e4b10d6b286dbe38047e9c064b7f Mon Sep 17 00:00:00 2001 From: DHR60 Date: Sat, 31 Jan 2026 23:54:49 +0800 Subject: [PATCH 2/2] Add xray v26.1.31 mkcp support --- v2rayN/ServiceLib/Global.cs | 10 ++++++ v2rayN/ServiceLib/Models/V2rayConfig.cs | 7 +---- .../CoreConfig/V2ray/V2rayOutboundService.cs | 31 +++++++++++++++---- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index 94a66fa5..6c22a045 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -288,6 +288,16 @@ public class Global "dns" ]; + public static readonly Dictionary KcpHeaderMaskMap = new() + { + { "srtp", "header-srtp" }, + { "utp", "header-utp" }, + { "wechat-video", "header-wechat" }, + { "dtls", "header-dtls" }, + { "wireguard", "header-wireguard" }, + { "dns", "header-dns" } + }; + public static readonly List CoreTypes = [ "Xray", diff --git a/v2rayN/ServiceLib/Models/V2rayConfig.cs b/v2rayN/ServiceLib/Models/V2rayConfig.cs index 90084b8f..acf17532 100644 --- a/v2rayN/ServiceLib/Models/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/V2rayConfig.cs @@ -388,8 +388,6 @@ public class Header4Ray public object request { get; set; } public object response { get; set; } - - public string? domain { get; set; } } public class KcpSettings4Ray @@ -407,10 +405,6 @@ public class KcpSettings4Ray public int readBufferSize { get; set; } public int writeBufferSize { get; set; } - - public Header4Ray header { get; set; } - - public string seed { get; set; } } public class WsSettings4Ray @@ -499,6 +493,7 @@ public class Mask4Ray public class MaskSettings4Ray { public string? password { get; set; } + public string? domain { get; set; } } public class AccountsItem4Ray diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs index 71d3ef6c..f2117063 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs @@ -364,14 +364,33 @@ public partial class CoreConfigV2rayService kcpSettings.congestion = _config.KcpItem.Congestion; kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize; kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize; - kcpSettings.header = new Header4Ray + streamSettings.finalmask ??= new(); + if (Global.KcpHeaderMaskMap.TryGetValue(node.HeaderType, out var header)) { - type = node.HeaderType, - domain = host.NullIfEmpty() - }; - if (path.IsNotEmpty()) + streamSettings.finalmask.udp = + [ + new Mask4Ray + { + type = header, + settings = node.HeaderType == "dns" && !host.IsNullOrEmpty() ? new MaskSettings4Ray { domain = host } : null + } + ]; + } + streamSettings.finalmask.udp ??= []; + if (path.IsNullOrEmpty()) { - kcpSettings.seed = path; + streamSettings.finalmask.udp.Add(new Mask4Ray + { + type = "mkcp-original" + }); + } + else + { + streamSettings.finalmask.udp.Add(new Mask4Ray + { + type = "mkcp-aes128gcm", + settings = new MaskSettings4Ray { password = path } + }); } streamSettings.kcpSettings = kcpSettings; break;