Skip to content

Commit

Permalink
Add splithttp transport for xray
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Jun 20, 2024
1 parent 123c49c commit 522571f
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 19 deletions.
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Enums/ETransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public enum ETransport
kcp,
ws,
httpupgrade,
splithttp,
h2,
http,
quic,
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ internal class Global
public static readonly List<string> 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<string> 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<string> Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" };
public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "h2", "quic", "grpc" };
public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "splithttp", "h2", "quic", "grpc" };
public static readonly List<string> KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" };
public static readonly List<string> CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" };
public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" };
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public int GenerateClientConfigContent(ProfileItem node, out SingboxConfig? sing
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;
Expand Down
20 changes: 20 additions & 0 deletions v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ private int GenBoundStreamSettings(ProfileItem node, StreamSettings4Ray streamSe
publicKey = node.publicKey,
shortId = node.shortId,
spiderX = node.spiderX,
show = false,
};

streamSettings.realitySettings = realitySettings;
Expand Down Expand Up @@ -630,6 +631,25 @@ private int GenBoundStreamSettings(ProfileItem node, StreamSettings4Ray streamSe
}
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):
Expand Down
2 changes: 2 additions & 0 deletions v2rayN/v2rayN/Handler/Fmt/BaseFmt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected static int GetStdTransport(ProfileItem item, string? securityDef, ref

case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
case nameof(ETransport.splithttp):
if (!Utils.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.requestHost));
Expand Down Expand Up @@ -152,6 +153,7 @@ protected static int ResolveStdTransport(NameValueCollection query, ref ProfileI

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;
Expand Down
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Handler/Fmt/VmessFmt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ internal class VmessFmt : BaseFmt

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);
Expand Down
34 changes: 25 additions & 9 deletions v2rayN/v2rayN/Models/V2rayConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,47 +421,52 @@ public class StreamSettings4Ray
/// <summary>
///
/// </summary>
public TlsSettings4Ray tlsSettings { get; set; }
public TlsSettings4Ray? tlsSettings { get; set; }

/// <summary>
/// Tcp传输额外设置
/// </summary>
public TcpSettings4Ray tcpSettings { get; set; }
public TcpSettings4Ray? tcpSettings { get; set; }

/// <summary>
/// Kcp传输额外设置
/// </summary>
public KcpSettings4Ray kcpSettings { get; set; }
public KcpSettings4Ray? kcpSettings { get; set; }

/// <summary>
/// ws传输额外设置
/// </summary>
public WsSettings4Ray wsSettings { get; set; }
public WsSettings4Ray? wsSettings { get; set; }

/// <summary>
///
/// </summary>
public HttpupgradeSettings4Ray? httpupgradeSettings { get; set; }

/// <summary>
///
/// </summary>
public SplithttpSettings4Ray? splithttpSettings { get; set; }

/// <summary>
/// h2传输额外设置
/// </summary>
public HttpSettings4Ray httpSettings { get; set; }
public HttpSettings4Ray? httpSettings { get; set; }

/// <summary>
/// QUIC
/// </summary>
public QuicSettings4Ray quicSettings { get; set; }
public QuicSettings4Ray? quicSettings { get; set; }

/// <summary>
/// VLESS only
/// </summary>
public TlsSettings4Ray realitySettings { get; set; }
public TlsSettings4Ray? realitySettings { get; set; }

/// <summary>
/// grpc
/// </summary>
public GrpcSettings4Ray grpcSettings { get; set; }
public GrpcSettings4Ray? grpcSettings { get; set; }

/// <summary>
/// sockopt
Expand All @@ -488,7 +493,7 @@ public class TlsSettings4Ray

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; }
Expand Down Expand Up @@ -608,6 +613,17 @@ public class HttpupgradeSettings4Ray
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
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN/Resx/ResUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions v2rayN/v2rayN/Resx/ResUI.resx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
<value>Please fill in the correct custom DNS</value>
</data>
<data name="TransportPathTip1" xml:space="preserve">
<value>*ws/httpupgrade path</value>
<value>*ws/httpupgrade/splithttp path</value>
</data>
<data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value>
Expand All @@ -374,7 +374,7 @@
<value>*http host Separated by commas (,)</value>
</data>
<data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws/httpupgrade host</value>
<value>*ws/httpupgrade/splithttp host</value>
</data>
<data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host Separated by commas (,)</value>
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
<value>请填写正确的自定义DNS</value>
</data>
<data name="TransportPathTip1" xml:space="preserve">
<value>*ws/httpupgrade path</value>
<value>*ws/httpupgrade/splithttp path</value>
</data>
<data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value>
Expand All @@ -374,7 +374,7 @@
<value>*http host中间逗号(,)分隔</value>
</data>
<data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws/httpupgrade host</value>
<value>*ws/httpupgrade/splithttp host</value>
</data>
<data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host中间逗号(,)分隔</value>
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
<value>請填寫正確的自訂DNS</value>
</data>
<data name="TransportPathTip1" xml:space="preserve">
<value>*ws/httpupgrade path</value>
<value>*ws/httpupgrade/splithttp path</value>
</data>
<data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value>
Expand All @@ -373,7 +373,7 @@
<value>*http host中間逗號(,)分隔</value>
</data>
<data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws/httpupgrade host</value>
<value>*ws/httpupgrade/splithttp host</value>
</data>
<data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host中間逗號(,)分隔</value>
Expand Down
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Views/AddServerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ private void SetTips()

case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
case nameof(ETransport.splithttp):
tipRequestHost.Text = ResUI.TransportRequestHostTip2;
tipPath.Text = ResUI.TransportPathTip1;
break;
Expand Down

0 comments on commit 522571f

Please sign in to comment.