57 lines
1.4 KiB
C#
57 lines
1.4 KiB
C#
using System.Text.Json.Nodes;
|
|
|
|
namespace Proxd_man.Config.Outbound;
|
|
|
|
/// <summary>
|
|
/// Xray-Core 的 ShadowSocks 出站配置.
|
|
///
|
|
/// 目前不支持设置多服务器.
|
|
/// </summary>
|
|
public class ShadowSocksOutboundSetting : BaseOutboundSetting
|
|
{
|
|
|
|
public string? UserEmail { get; init; } = null;
|
|
public required string Method { get; init; }
|
|
public required string Address { get; init; }
|
|
public int Port { get; init; }
|
|
public required string Password { get; init; }
|
|
public bool EnableUdpOverTcp { get; init; } = false;
|
|
public uint? UdpOverTcpVersion { get; init; } = null;
|
|
|
|
public ShadowSocksOutboundSetting()
|
|
{
|
|
Protocol = OutboundProtocolType.Shadowsocks;
|
|
}
|
|
|
|
public override string GetTag()
|
|
{
|
|
return $"ShadowSocks-{GetHashCode()}";
|
|
}
|
|
|
|
protected override JsonObject GetProtocolSetting()
|
|
{
|
|
var root = new JsonObject();
|
|
|
|
var setting = new JsonObject
|
|
{
|
|
{ "address", Address },
|
|
{ "port", Port },
|
|
{ "method", Method },
|
|
{ "password", Password },
|
|
{ "uot", EnableUdpOverTcp }
|
|
};
|
|
|
|
if (EnableUdpOverTcp)
|
|
{
|
|
setting.Add("UoTVersion", UdpOverTcpVersion);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(UserEmail))
|
|
{
|
|
setting.Add("email", UserEmail);
|
|
}
|
|
|
|
root.Add("servers", new JsonArray { setting });
|
|
return root;
|
|
}
|
|
} |