Add httpupgrade

pull/4848/head
2dust 2024-03-12 09:05:59 +08:00
parent e90353e550
commit 572c924e5c
12 changed files with 56 additions and 11 deletions

View File

@ -156,7 +156,7 @@ namespace v2rayN
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", "h2", "quic", "grpc" };
public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "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" };

View File

@ -439,6 +439,12 @@ namespace v2rayN.Handler
};
}
break;
case nameof(ETransport.httpupgrade):
transport.type = nameof(ETransport.httpupgrade);
transport.path = Utile.IsNullOrEmpty(node.path) ? null : node.path;
transport.host = Utile.IsNullOrEmpty(node.requestHost) ? null : node.requestHost;
break;
case nameof(ETransport.quic):
transport.type = nameof(ETransport.quic);

View File

@ -606,6 +606,21 @@ namespace v2rayN.Handler
}
streamSettings.wsSettings = wsSettings;
break;
//httpupgrade
case nameof(ETransport.httpupgrade):
HttpupgradeSettings4Ray httpupgradeSettings = new();
if (!string.IsNullOrWhiteSpace(node.path))
{
httpupgradeSettings.path = node.path;
}
if (!string.IsNullOrWhiteSpace(host))
{
httpupgradeSettings.host = host;
}
streamSettings.httpupgradeSettings = httpupgradeSettings;
break;
//h2
case nameof(ETransport.h2):

View File

@ -331,6 +331,7 @@ namespace v2rayN.Handler
break;
case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
if (!Utile.IsNullOrEmpty(item.requestHost))
{
dicQuery.Add("host", Utile.UrlEncode(item.requestHost));
@ -609,6 +610,7 @@ namespace v2rayN.Handler
break;
case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
string p1 = query["path"] ?? "/";
string h1 = query["host"] ?? "";
i.requestHost = Utile.UrlDecode(h1);
@ -960,6 +962,7 @@ namespace v2rayN.Handler
break;
case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
item.requestHost = Utile.UrlDecode(query["host"] ?? "");
item.path = Utile.UrlDecode(query["path"] ?? "/");
break;

View File

@ -5,6 +5,7 @@
tcp,
kcp,
ws,
httpupgrade,
h2,
http,
quic,

View File

@ -159,7 +159,7 @@
public class Transport4Sbox
{
public string? type { get; set; }
public List<string>? host { get; set; }
public object? host { get; set; }
public string? path { get; set; }
public Headers4Sbox? headers { get; set; }

View File

@ -431,6 +431,11 @@ namespace v2rayN.Model
/// </summary>
public WsSettings4Ray wsSettings { get; set; }
/// <summary>
///
/// </summary>
public HttpupgradeSettings4Ray? httpupgradeSettings { get; set; }
/// <summary>
/// h2传输额外设置
/// </summary>
@ -582,6 +587,20 @@ namespace v2rayN.Model
[JsonPropertyName("User-Agent")]
public string UserAgent { get; set; }
}
public class HttpupgradeSettings4Ray
{
/// <summary>
///
/// </summary>
public string? path { get; set; }
/// <summary>
///
/// </summary>
public string? host { get; set; }
}
public class HttpSettings4Ray
{

View File

@ -3203,7 +3203,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 *ws path 的本地化字符串。
/// 查找类似 *ws/httpupgrade path 的本地化字符串。
/// </summary>
public static string TransportPathTip1 {
get {
@ -3257,7 +3257,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 *ws host 的本地化字符串。
/// 查找类似 *ws/httpupgrade host 的本地化字符串。
/// </summary>
public static string TransportRequestHostTip2 {
get {

View File

@ -359,7 +359,7 @@
<value>Please fill in the correct custom DNS</value>
</data>
<data name="TransportPathTip1" xml:space="preserve">
<value>*ws path</value>
<value>*ws/httpupgrade path</value>
</data>
<data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value>
@ -374,7 +374,7 @@
<value>*http host Separated by commas (,)</value>
</data>
<data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws host</value>
<value>*ws/httpupgrade host</value>
</data>
<data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host Separated by commas (,)</value>

View File

@ -359,7 +359,7 @@
<value>请填写正确的自定义DNS</value>
</data>
<data name="TransportPathTip1" xml:space="preserve">
<value>*ws path</value>
<value>*ws/httpupgrade path</value>
</data>
<data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value>
@ -374,7 +374,7 @@
<value>*http host中间逗号(,)分隔</value>
</data>
<data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws host</value>
<value>*ws/httpupgrade host</value>
</data>
<data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host中间逗号(,)分隔</value>

View File

@ -358,7 +358,7 @@
<value>請填寫正確的自訂DNS</value>
</data>
<data name="TransportPathTip1" xml:space="preserve">
<value>*ws path</value>
<value>*ws/httpupgrade path</value>
</data>
<data name="TransportPathTip2" xml:space="preserve">
<value>*h2 path</value>
@ -373,7 +373,7 @@
<value>*http host中間逗號(,)分隔</value>
</data>
<data name="TransportRequestHostTip2" xml:space="preserve">
<value>*ws host</value>
<value>*ws/httpupgrade host</value>
</data>
<data name="TransportRequestHostTip3" xml:space="preserve">
<value>*h2 host中間逗號(,)分隔</value>

View File

@ -279,7 +279,7 @@ namespace v2rayN.Views
return;
}
if (network == Global.DefaultNetwork)
if (network == nameof(ETransport.tcp))
{
cmbHeaderType.Items.Add(Global.None);
cmbHeaderType.Items.Add(Global.TcpHeaderHttp);
@ -329,6 +329,7 @@ namespace v2rayN.Views
break;
case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade):
tipRequestHost.Text = ResUI.TransportRequestHostTip2;
tipPath.Text = ResUI.TransportPathTip1;
break;