From 522571f0b31a11629ca4debf4175974b39d83dd3 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:20:05 +0800 Subject: [PATCH] Add splithttp transport for xray https://github.com/XTLS/Xray-core/releases/tag/v1.8.15 --- v2rayN/v2rayN/Enums/ETransport.cs | 1 + v2rayN/v2rayN/Global.cs | 2 +- .../Handler/CoreConfig/CoreConfigSingbox.cs | 2 +- .../Handler/CoreConfig/CoreConfigV2ray.cs | 20 +++++++++++ v2rayN/v2rayN/Handler/Fmt/BaseFmt.cs | 2 ++ v2rayN/v2rayN/Handler/Fmt/VmessFmt.cs | 1 + v2rayN/v2rayN/Models/V2rayConfig.cs | 34 ++++++++++++++----- v2rayN/v2rayN/Resx/ResUI.Designer.cs | 4 +-- v2rayN/v2rayN/Resx/ResUI.resx | 4 +-- v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx | 4 +-- v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx | 4 +-- v2rayN/v2rayN/Views/AddServerWindow.xaml.cs | 1 + 12 files changed, 60 insertions(+), 19 deletions(-) diff --git a/v2rayN/v2rayN/Enums/ETransport.cs b/v2rayN/v2rayN/Enums/ETransport.cs index 7ad8a66e..349d68e7 100644 --- a/v2rayN/v2rayN/Enums/ETransport.cs +++ b/v2rayN/v2rayN/Enums/ETransport.cs @@ -6,6 +6,7 @@ kcp, ws, httpupgrade, + splithttp, h2, http, quic, diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index 28b9331f..b325da28 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -157,7 +157,7 @@ namespace v2rayN public static readonly List SsSecuritiesInXray = new() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "none", "plain", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" }; public static readonly List SsSecuritiesInSingbox = new() { "aes-256-gcm", "aes-192-gcm", "aes-128-gcm", "chacha20-ietf-poly1305", "xchacha20-ietf-poly1305", "none", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", "aes-128-ctr", "aes-192-ctr", "aes-256-ctr", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "rc4-md5", "chacha20-ietf", "xchacha20" }; public static readonly List Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" }; - public static readonly List Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "h2", "quic", "grpc" }; + public static readonly List Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "splithttp", "h2", "quic", "grpc" }; public static readonly List KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" }; public static readonly List CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" }; public static readonly List CoreTypes4VLESS = new() { "Xray", "sing_box" }; diff --git a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs index 08cef896..6ceb3154 100644 --- a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs +++ b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs @@ -26,7 +26,7 @@ namespace v2rayN.Handler.CoreConfig msg = ResUI.CheckServerSettings; return -1; } - if (node.GetNetwork() == nameof(ETransport.kcp)) + if (node.GetNetwork() is nameof(ETransport.kcp) or nameof(ETransport.splithttp)) { msg = ResUI.Incorrectconfiguration + $" - {node.GetNetwork()}"; return -1; diff --git a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs index e1820080..9a912c9a 100644 --- a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs +++ b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs @@ -565,6 +565,7 @@ namespace v2rayN.Handler.CoreConfig publicKey = node.publicKey, shortId = node.shortId, spiderX = node.spiderX, + show = false, }; streamSettings.realitySettings = realitySettings; @@ -630,6 +631,25 @@ namespace v2rayN.Handler.CoreConfig } streamSettings.httpupgradeSettings = httpupgradeSettings; + break; + //splithttp + case nameof(ETransport.splithttp): + SplithttpSettings4Ray splithttpSettings = new() + { + maxUploadSize = 1000000, + maxConcurrentUploads = 10 + }; + + if (!Utils.IsNullOrEmpty(node.path)) + { + splithttpSettings.path = node.path; + } + if (!Utils.IsNullOrEmpty(host)) + { + splithttpSettings.host = host; + } + streamSettings.splithttpSettings = splithttpSettings; + break; //h2 case nameof(ETransport.h2): diff --git a/v2rayN/v2rayN/Handler/Fmt/BaseFmt.cs b/v2rayN/v2rayN/Handler/Fmt/BaseFmt.cs index 8bc9bb48..42b76252 100644 --- a/v2rayN/v2rayN/Handler/Fmt/BaseFmt.cs +++ b/v2rayN/v2rayN/Handler/Fmt/BaseFmt.cs @@ -81,6 +81,7 @@ namespace v2rayN.Handler.Fmt case nameof(ETransport.ws): case nameof(ETransport.httpupgrade): + case nameof(ETransport.splithttp): if (!Utils.IsNullOrEmpty(item.requestHost)) { dicQuery.Add("host", Utils.UrlEncode(item.requestHost)); @@ -152,6 +153,7 @@ namespace v2rayN.Handler.Fmt case nameof(ETransport.ws): case nameof(ETransport.httpupgrade): + case nameof(ETransport.splithttp): item.requestHost = Utils.UrlDecode(query["host"] ?? ""); item.path = Utils.UrlDecode(query["path"] ?? "/"); break; diff --git a/v2rayN/v2rayN/Handler/Fmt/VmessFmt.cs b/v2rayN/v2rayN/Handler/Fmt/VmessFmt.cs index 5e0b230f..636367da 100644 --- a/v2rayN/v2rayN/Handler/Fmt/VmessFmt.cs +++ b/v2rayN/v2rayN/Handler/Fmt/VmessFmt.cs @@ -156,6 +156,7 @@ namespace v2rayN.Handler.Fmt case nameof(ETransport.ws): case nameof(ETransport.httpupgrade): + case nameof(ETransport.splithttp): string p1 = query["path"] ?? "/"; string h1 = query["host"] ?? ""; item.requestHost = Utils.UrlDecode(h1); diff --git a/v2rayN/v2rayN/Models/V2rayConfig.cs b/v2rayN/v2rayN/Models/V2rayConfig.cs index 459f3b83..e693f0cc 100644 --- a/v2rayN/v2rayN/Models/V2rayConfig.cs +++ b/v2rayN/v2rayN/Models/V2rayConfig.cs @@ -421,47 +421,52 @@ namespace v2rayN.Models /// /// /// - public TlsSettings4Ray tlsSettings { get; set; } + public TlsSettings4Ray? tlsSettings { get; set; } /// /// Tcp传输额外设置 /// - public TcpSettings4Ray tcpSettings { get; set; } + public TcpSettings4Ray? tcpSettings { get; set; } /// /// Kcp传输额外设置 /// - public KcpSettings4Ray kcpSettings { get; set; } + public KcpSettings4Ray? kcpSettings { get; set; } /// /// ws传输额外设置 /// - public WsSettings4Ray wsSettings { get; set; } + public WsSettings4Ray? wsSettings { get; set; } /// /// /// public HttpupgradeSettings4Ray? httpupgradeSettings { get; set; } + /// + /// + /// + public SplithttpSettings4Ray? splithttpSettings { get; set; } + /// /// h2传输额外设置 /// - public HttpSettings4Ray httpSettings { get; set; } + public HttpSettings4Ray? httpSettings { get; set; } /// /// QUIC /// - public QuicSettings4Ray quicSettings { get; set; } + public QuicSettings4Ray? quicSettings { get; set; } /// /// VLESS only /// - public TlsSettings4Ray realitySettings { get; set; } + public TlsSettings4Ray? realitySettings { get; set; } /// /// grpc /// - public GrpcSettings4Ray grpcSettings { get; set; } + public GrpcSettings4Ray? grpcSettings { get; set; } /// /// sockopt @@ -488,7 +493,7 @@ namespace v2rayN.Models public string? fingerprint { get; set; } - public bool? show { get; set; } = false; + public bool? show { get; set; } public string? publicKey { get; set; } public string? shortId { get; set; } public string? spiderX { get; set; } @@ -608,6 +613,17 @@ namespace v2rayN.Models public string? host { get; set; } } + public class SplithttpSettings4Ray + { + public string? path { get; set; } + + public string? host { get; set; } + + public int? maxUploadSize { get; set; } + + public int? maxConcurrentUploads { get; set; } + } + public class HttpSettings4Ray { /// diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs index 45c7d3c3..52099eff 100644 --- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs +++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs @@ -3266,7 +3266,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 *ws/httpupgrade path 的本地化字符串。 + /// 查找类似 *ws/httpupgrade/splithttp path 的本地化字符串。 /// public static string TransportPathTip1 { get { @@ -3320,7 +3320,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 *ws/httpupgrade host 的本地化字符串。 + /// 查找类似 *ws/httpupgrade/splithttp host 的本地化字符串。 /// public static string TransportRequestHostTip2 { get { diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index d3b17f9a..4dfd5108 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -359,7 +359,7 @@ Please fill in the correct custom DNS - *ws/httpupgrade path + *ws/httpupgrade/splithttp path *h2 path @@ -374,7 +374,7 @@ *http host Separated by commas (,) - *ws/httpupgrade host + *ws/httpupgrade/splithttp host *h2 host Separated by commas (,) diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx index 56b28678..4a46b98e 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -359,7 +359,7 @@ 请填写正确的自定义DNS - *ws/httpupgrade path + *ws/httpupgrade/splithttp path *h2 path @@ -374,7 +374,7 @@ *http host中间逗号(,)分隔 - *ws/httpupgrade host + *ws/httpupgrade/splithttp host *h2 host中间逗号(,)分隔 diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx index 7367329e..df684d88 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx @@ -358,7 +358,7 @@ 請填寫正確的自訂DNS - *ws/httpupgrade path + *ws/httpupgrade/splithttp path *h2 path @@ -373,7 +373,7 @@ *http host中間逗號(,)分隔 - *ws/httpupgrade host + *ws/httpupgrade/splithttp host *h2 host中間逗號(,)分隔 diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs index 17d43528..1304a758 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs @@ -333,6 +333,7 @@ namespace v2rayN.Views case nameof(ETransport.ws): case nameof(ETransport.httpupgrade): + case nameof(ETransport.splithttp): tipRequestHost.Text = ResUI.TransportRequestHostTip2; tipPath.Text = ResUI.TransportPathTip1; break;