50 lines
1.3 KiB
C#
50 lines
1.3 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 override string GetTag()
|
|
{
|
|
return $"ShadowSocks-{GetHashCode()}";
|
|
}
|
|
|
|
protected override JsonObject GetProtocolSetting()
|
|
{
|
|
var root = new JsonObject();
|
|
|
|
var setting = new JsonObject();
|
|
setting.Add("address", Address);
|
|
setting.Add("port", Port);
|
|
setting.Add("method", Method);
|
|
setting.Add("password", Password);
|
|
|
|
setting.Add("uot", EnableUdpOverTcp);
|
|
if (EnableUdpOverTcp)
|
|
{
|
|
setting.Add("UoTVersion", UdpOverTcpVersion);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(UserEmail))
|
|
{
|
|
setting.Add("email", UserEmail);
|
|
}
|
|
|
|
root.Add("servers", new JsonArray { setting });
|
|
return root;
|
|
}
|
|
} |