Add xray v26.1.31 mkcp support

This commit is contained in:
DHR60 2026-01-31 23:54:49 +08:00
parent e0402a03cd
commit 2a10634957
3 changed files with 36 additions and 12 deletions

View file

@ -288,6 +288,16 @@ public class Global
"dns" "dns"
]; ];
public static readonly Dictionary<string, string> 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<string> CoreTypes = public static readonly List<string> CoreTypes =
[ [
"Xray", "Xray",

View file

@ -388,8 +388,6 @@ public class Header4Ray
public object request { get; set; } public object request { get; set; }
public object response { get; set; } public object response { get; set; }
public string? domain { get; set; }
} }
public class KcpSettings4Ray public class KcpSettings4Ray
@ -407,10 +405,6 @@ public class KcpSettings4Ray
public int readBufferSize { get; set; } public int readBufferSize { get; set; }
public int writeBufferSize { get; set; } public int writeBufferSize { get; set; }
public Header4Ray header { get; set; }
public string seed { get; set; }
} }
public class WsSettings4Ray public class WsSettings4Ray
@ -499,6 +493,7 @@ public class Mask4Ray
public class MaskSettings4Ray public class MaskSettings4Ray
{ {
public string? password { get; set; } public string? password { get; set; }
public string? domain { get; set; }
} }
public class AccountsItem4Ray public class AccountsItem4Ray

View file

@ -364,14 +364,33 @@ public partial class CoreConfigV2rayService
kcpSettings.congestion = _config.KcpItem.Congestion; kcpSettings.congestion = _config.KcpItem.Congestion;
kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize; kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize;
kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize; kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize;
kcpSettings.header = new Header4Ray streamSettings.finalmask ??= new();
if (Global.KcpHeaderMaskMap.TryGetValue(node.HeaderType, out var header))
{ {
type = node.HeaderType, streamSettings.finalmask.udp =
domain = host.NullIfEmpty() [
}; new Mask4Ray
if (path.IsNotEmpty()) {
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; streamSettings.kcpSettings = kcpSettings;
break; break;