Add xhttp mode for xray

https://github.com/XTLS/Xray-core/pull/3994
pull/6079/head
2dust 2024-11-14 09:48:43 +08:00
parent 04efed2079
commit d781c768e9
12 changed files with 80 additions and 4 deletions

View File

@ -187,6 +187,7 @@
public static readonly List<string> DomainMatchers = new() { "linear", "mph", "" }; public static readonly List<string> DomainMatchers = new() { "linear", "mph", "" };
public static readonly List<string> Fingerprints = new() { "chrome", "firefox", "safari", "ios", "android", "edge", "360", "qq", "random", "randomized", "" }; public static readonly List<string> Fingerprints = new() { "chrome", "firefox", "safari", "ios", "android", "edge", "360", "qq", "random", "randomized", "" };
public static readonly List<string> UserAgent = new() { "chrome", "firefox", "safari", "edge", "none" }; public static readonly List<string> UserAgent = new() { "chrome", "firefox", "safari", "edge", "none" };
public static readonly List<string> XhttpMode = new() { "auto", "packet-up", "stream-up" };
public static readonly List<string> AllowInsecure = new() { "true", "false", "" }; public static readonly List<string> AllowInsecure = new() { "true", "false", "" };
public static readonly List<string> DomainStrategy4Freedoms = new() { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" }; public static readonly List<string> DomainStrategy4Freedoms = new() { "AsIs", "UseIP", "UseIPv4", "UseIPv6", "" };
@ -206,9 +207,9 @@
public static readonly List<string> SingboxMuxs = new() { "h2mux", "smux", "yamux", "" }; public static readonly List<string> SingboxMuxs = new() { "h2mux", "smux", "yamux", "" };
public static readonly List<string> TuicCongestionControls = new() { "cubic", "new_reno", "bbr" }; public static readonly List<string> TuicCongestionControls = new() { "cubic", "new_reno", "bbr" };
public static readonly List<string> allowSelectType = new List<string> { "selector", "urltest", "loadbalance", "fallback" }; public static readonly List<string> allowSelectType = new() { "selector", "urltest", "loadbalance", "fallback" };
public static readonly List<string> notAllowTestType = new List<string> { "selector", "urltest", "direct", "reject", "compatible", "pass", "loadbalance", "fallback" }; public static readonly List<string> notAllowTestType = new() { "selector", "urltest", "direct", "reject", "compatible", "pass", "loadbalance", "fallback" };
public static readonly List<string> proxyVehicleType = new List<string> { "file", "http" }; public static readonly List<string> proxyVehicleType = new() { "file", "http" };
#endregion const #endregion const
} }

View File

@ -83,6 +83,16 @@ namespace ServiceLib.Handler.Fmt
case nameof(ETransport.ws): case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade): case nameof(ETransport.httpupgrade):
if (Utils.IsNotEmpty(item.RequestHost))
{
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
}
if (Utils.IsNotEmpty(item.Path))
{
dicQuery.Add("path", Utils.UrlEncode(item.Path));
}
break;
case nameof(ETransport.splithttp): case nameof(ETransport.splithttp):
case nameof(ETransport.xhttp): case nameof(ETransport.xhttp):
if (Utils.IsNotEmpty(item.RequestHost)) if (Utils.IsNotEmpty(item.RequestHost))
@ -93,6 +103,10 @@ namespace ServiceLib.Handler.Fmt
{ {
dicQuery.Add("path", Utils.UrlEncode(item.Path)); dicQuery.Add("path", Utils.UrlEncode(item.Path));
} }
if (Utils.IsNotEmpty(item.HeaderType) && Global.XhttpMode.Contains(item.HeaderType))
{
dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType));
}
break; break;
case nameof(ETransport.http): case nameof(ETransport.http):
@ -157,10 +171,15 @@ namespace ServiceLib.Handler.Fmt
case nameof(ETransport.ws): case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade): case nameof(ETransport.httpupgrade):
item.RequestHost = Utils.UrlDecode(query["host"] ?? "");
item.Path = Utils.UrlDecode(query["path"] ?? "/");
break;
case nameof(ETransport.splithttp): case nameof(ETransport.splithttp):
case nameof(ETransport.xhttp): case nameof(ETransport.xhttp):
item.RequestHost = Utils.UrlDecode(query["host"] ?? ""); item.RequestHost = Utils.UrlDecode(query["host"] ?? "");
item.Path = Utils.UrlDecode(query["path"] ?? "/"); item.Path = Utils.UrlDecode(query["path"] ?? "/");
item.HeaderType = Utils.UrlDecode(query["mode"] ?? "");
break; break;
case nameof(ETransport.http): case nameof(ETransport.http):

View File

@ -348,6 +348,7 @@ namespace ServiceLib.Models
{ {
public string? path { get; set; } public string? path { get; set; }
public string? host { get; set; } public string? host { get; set; }
public string? mode { get; set; }
public string? scMaxEachPostBytes { get; set; } public string? scMaxEachPostBytes { get; set; }
public string? scMaxConcurrentPosts { get; set; } public string? scMaxConcurrentPosts { get; set; }
public string? scMinPostsIntervalMs { get; set; } public string? scMinPostsIntervalMs { get; set; }

View File

@ -3733,6 +3733,15 @@ namespace ServiceLib.Resx {
} }
} }
/// <summary>
/// 查找类似 *xhttp mode 的本地化字符串。
/// </summary>
public static string TransportHeaderTypeTip5 {
get {
return ResourceManager.GetString("TransportHeaderTypeTip5", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 *ws/httpupgrade/xhttp path 的本地化字符串。 /// 查找类似 *ws/httpupgrade/xhttp path 的本地化字符串。
/// </summary> /// </summary>

View File

@ -1381,4 +1381,7 @@
<data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve">
<value>Please do not run this app with sudo</value> <value>Please do not run this app with sudo</value>
</data> </data>
<data name="TransportHeaderTypeTip5" xml:space="preserve">
<value>*xhttp mode</value>
</data>
</root> </root>

View File

@ -1381,4 +1381,7 @@
<data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve">
<value>Please do not run this app with sudo</value> <value>Please do not run this app with sudo</value>
</data> </data>
<data name="TransportHeaderTypeTip5" xml:space="preserve">
<value>*xhttp mode</value>
</data>
</root> </root>

View File

@ -1381,4 +1381,7 @@
<data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve">
<value>Please do not run this app with sudo</value> <value>Please do not run this app with sudo</value>
</data> </data>
<data name="TransportHeaderTypeTip5" xml:space="preserve">
<value>*xhttp mode</value>
</data>
</root> </root>

View File

@ -1378,4 +1378,7 @@
<data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve">
<value>请不要用sudo运行本app</value> <value>请不要用sudo运行本app</value>
</data> </data>
<data name="TransportHeaderTypeTip5" xml:space="preserve">
<value>*xhttp 模式</value>
</data>
</root> </root>

View File

@ -1366,7 +1366,7 @@
<data name="TbPath7" xml:space="preserve"> <data name="TbPath7" xml:space="preserve">
<value>混淆密碼(obfs password)</value> <value>混淆密碼(obfs password)</value>
</data> </data>
<data name="TbSettingsLinuxSudoPassword" xml:space="preserve"> <data name="TbSettingsLinuxSudoPassword" xml:space="preserve">
<value>Linux系統的sudo密碼</value> <value>Linux系統的sudo密碼</value>
</data> </data>
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
@ -1378,4 +1378,7 @@
<data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordNotSudoRunApp" xml:space="preserve">
<value>請不要用sudo來運行本app</value> <value>請不要用sudo來運行本app</value>
</data> </data>
<data name="TransportHeaderTypeTip5" xml:space="preserve">
<value>*xhttp 模式</value>
</data>
</root> </root>

View File

@ -945,6 +945,11 @@ namespace ServiceLib.Services.CoreConfig
{ {
xhttpSettings.host = host; xhttpSettings.host = host;
} }
if (Utils.IsNotEmpty(node.HeaderType) && Global.XhttpMode.Contains(node.HeaderType))
{
xhttpSettings.mode = node.HeaderType;
}
streamSettings.xhttpSettings = xhttpSettings; streamSettings.xhttpSettings = xhttpSettings;
break; break;

View File

@ -299,6 +299,13 @@ namespace v2rayN.Desktop.Views
cmbHeaderType.Items.Add(it); cmbHeaderType.Items.Add(it);
}); });
} }
else if (network is nameof(ETransport.splithttp) or nameof(ETransport.xhttp))
{
Global.XhttpMode.ForEach(it =>
{
cmbHeaderType.Items.Add(it);
});
}
else if (network == nameof(ETransport.grpc)) else if (network == nameof(ETransport.grpc))
{ {
cmbHeaderType.Items.Add(Global.GrpcGunMode); cmbHeaderType.Items.Add(Global.GrpcGunMode);
@ -337,10 +344,16 @@ namespace v2rayN.Desktop.Views
case nameof(ETransport.ws): case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade): case nameof(ETransport.httpupgrade):
tipRequestHost.Text = ResUI.TransportRequestHostTip2;
tipPath.Text = ResUI.TransportPathTip1;
break;
case nameof(ETransport.splithttp): case nameof(ETransport.splithttp):
case nameof(ETransport.xhttp): case nameof(ETransport.xhttp):
tipRequestHost.Text = ResUI.TransportRequestHostTip2; tipRequestHost.Text = ResUI.TransportRequestHostTip2;
tipPath.Text = ResUI.TransportPathTip1; tipPath.Text = ResUI.TransportPathTip1;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip5;
labHeaderType.IsVisible = false;
break; break;
case nameof(ETransport.h2): case nameof(ETransport.h2):

View File

@ -294,6 +294,13 @@ namespace v2rayN.Views
cmbHeaderType.Items.Add(it); cmbHeaderType.Items.Add(it);
}); });
} }
else if (network is nameof(ETransport.splithttp) or nameof(ETransport.xhttp))
{
Global.XhttpMode.ForEach(it =>
{
cmbHeaderType.Items.Add(it);
});
}
else if (network == nameof(ETransport.grpc)) else if (network == nameof(ETransport.grpc))
{ {
cmbHeaderType.Items.Add(Global.GrpcGunMode); cmbHeaderType.Items.Add(Global.GrpcGunMode);
@ -332,10 +339,16 @@ namespace v2rayN.Views
case nameof(ETransport.ws): case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade): case nameof(ETransport.httpupgrade):
tipRequestHost.Text = ResUI.TransportRequestHostTip2;
tipPath.Text = ResUI.TransportPathTip1;
break;
case nameof(ETransport.splithttp): case nameof(ETransport.splithttp):
case nameof(ETransport.xhttp): case nameof(ETransport.xhttp):
tipRequestHost.Text = ResUI.TransportRequestHostTip2; tipRequestHost.Text = ResUI.TransportRequestHostTip2;
tipPath.Text = ResUI.TransportPathTip1; tipPath.Text = ResUI.TransportPathTip1;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip5;
labHeaderType.Visibility = Visibility.Hidden;
break; break;
case nameof(ETransport.h2): case nameof(ETransport.h2):