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> 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> 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> 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> 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> CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" };
public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" }; public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" };

View File

@ -439,6 +439,12 @@ namespace v2rayN.Handler
}; };
} }
break; 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): case nameof(ETransport.quic):
transport.type = nameof(ETransport.quic); transport.type = nameof(ETransport.quic);

View File

@ -606,6 +606,21 @@ namespace v2rayN.Handler
} }
streamSettings.wsSettings = wsSettings; 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; break;
//h2 //h2
case nameof(ETransport.h2): case nameof(ETransport.h2):

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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