Skip to content

Commit

Permalink
Add obfs=http support for sing-box ss
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Feb 29, 2024
1 parent 11ec271 commit 6eee2c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 8 additions & 0 deletions v2rayN/v2rayN/Handler/CoreConfigSingbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ private int GenOutbound(ProfileItem node, Outbound4Sbox outbound)
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)
Expand Down
6 changes: 3 additions & 3 deletions v2rayN/v2rayN/Handler/ShareHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,13 @@ private static int GetStdTransport(ProfileItem item, string? securityDef, ref Di
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
{
Expand Down
2 changes: 2 additions & 0 deletions v2rayN/v2rayN/Model/SingboxConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public class Outbound4Sbox
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; }
Expand Down

0 comments on commit 6eee2c2

Please sign in to comment.