mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-14 19:45:45 +00:00
Add sing-box ua
This commit is contained in:
parent
0db611b7a9
commit
9267b3d036
10 changed files with 27 additions and 8 deletions
|
|
@ -237,6 +237,8 @@ public class Transport4Sbox
|
|||
public class Headers4Sbox
|
||||
{
|
||||
public string? Host { get; set; }
|
||||
[JsonPropertyName("User-Agent")]
|
||||
public string UserAgent { get; set; }
|
||||
}
|
||||
|
||||
public class HyObfs4Sbox
|
||||
|
|
|
|||
2
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
2
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
|
|
@ -3772,7 +3772,7 @@ namespace ServiceLib.Resx {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 This parameter is valid only for tcp/http and ws 的本地化字符串。
|
||||
/// 查找类似 This parameter is valid only for tcp/http, ws, gRPC and xhttp 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsDefUserAgentTips {
|
||||
get {
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>این پارامتر فقط برای tcp/http و ws معتبر است</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>FontFamily (نیاز به راه اندازی مجدد)</value>
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>Agent utilisateur (User-Agent)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>Valable uniquement pour les protocoles tcp/http et ws</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Police actuelle (redémarrage requis)</value>
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>Ez a paraméter csak tcp/http és ws esetén érvényes</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Betűtípus (újraindítást igényel)</value>
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>This parameter is valid only for tcp/http and ws</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Font family (requires restart)</value>
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>Параметр действует только для TCP/HTTP и WebSocket (WS)</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Шрифт (требуется перезапуск)</value>
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>用户代理 (User-Agent)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>仅对 tcp/http、ws 协议生效</value>
|
||||
<value>仅对 tcp/http、ws、gRPC、xhttp 生效</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>当前字体 (需重启)</value>
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>使用者代理 (User-Agent)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>僅對 TCP/HTTP、WS 協定生效</value>
|
||||
<value>僅對 TCP/HTTP、WS、gRPC、XHTTP 生效</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>目前字型 (需重啟)</value>
|
||||
|
|
|
|||
|
|
@ -438,6 +438,8 @@ public partial class CoreConfigSingboxService
|
|||
try
|
||||
{
|
||||
var transport = new Transport4Sbox();
|
||||
var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty;
|
||||
var useragentValue = Global.TcpHttpUserAgentTexts.GetValueOrDefault(useragent, useragent);
|
||||
|
||||
switch (_node.GetNetwork())
|
||||
{
|
||||
|
|
@ -453,6 +455,11 @@ public partial class CoreConfigSingboxService
|
|||
transport.type = nameof(ETransport.http);
|
||||
transport.host = _node.RequestHost.IsNullOrEmpty() ? null : Utils.String2List(_node.RequestHost);
|
||||
transport.path = _node.Path.NullIfEmpty();
|
||||
if (!useragentValue.IsNullOrEmpty())
|
||||
{
|
||||
transport.headers ??= new();
|
||||
transport.headers.UserAgent = useragentValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -494,12 +501,22 @@ public partial class CoreConfigSingboxService
|
|||
Host = _node.RequestHost
|
||||
};
|
||||
}
|
||||
if (!useragentValue.IsNullOrEmpty())
|
||||
{
|
||||
transport.headers ??= new();
|
||||
transport.headers.UserAgent = useragentValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.httpupgrade):
|
||||
transport.type = nameof(ETransport.httpupgrade);
|
||||
transport.path = _node.Path.NullIfEmpty();
|
||||
transport.host = _node.RequestHost.NullIfEmpty();
|
||||
if (!useragentValue.IsNullOrEmpty())
|
||||
{
|
||||
transport.headers ??= new();
|
||||
transport.headers.UserAgent = useragentValue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue