Add obfs=http support for sing-box ss

pull/4802/head
2dust 2024-02-29 10:11:27 +08:00
parent 11ec27147a
commit 6eee2c2342
3 changed files with 13 additions and 3 deletions

View File

@ -238,6 +238,14 @@ namespace v2rayN.Handler
outbound.method = LazyConfig.Instance.GetShadowsocksSecurities(node).Contains(node.security) ? node.security : Global.None;
outbound.password = node.id;
if (node.network == Global.DefaultNetwork
&& node.headerType == Global.TcpHeaderHttp
&& node.requestHost.IsNullOrEmpty() == false)
{
outbound.plugin = "obfs-local";
outbound.plugin_opts = $"obfs=http;obfs-host={node.requestHost};";
}
GenOutboundMux(node, outbound);
}
else if (node.configType == EConfigType.Socks)

View File

@ -686,13 +686,13 @@ namespace v2rayN.Handler
if (queryParameters["plugin"] != null)
{
//obfs-host exists
var obfsHost = queryParameters["plugin"].Split(';').FirstOrDefault(t => t.Contains("obfs-host"));
var obfsHost = queryParameters["plugin"]?.Split(';').FirstOrDefault(t => t.Contains("obfs-host"));
if (queryParameters["plugin"].Contains("obfs=http") && !Utile.IsNullOrEmpty(obfsHost))
{
obfsHost = obfsHost.Replace("obfs-host=", "");
obfsHost = obfsHost?.Replace("obfs-host=", "");
server.network = Global.DefaultNetwork;
server.headerType = Global.TcpHeaderHttp;
server.requestHost = obfsHost;
server.requestHost = obfsHost ?? "";
}
else
{

View File

@ -118,6 +118,8 @@
public string? peer_public_key { get; set; }
public int[]? reserved { get; set; }
public int? mtu { get; set; }
public string? plugin { get; set; }
public string? plugin_opts { get; set; }
public Tls4Sbox tls { get; set; }
public Multiplex4Sbox multiplex { get; set; }
public Transport4Sbox transport { get; set; }