refactor: 优化配置代码结构.
This commit is contained in:
@@ -24,7 +24,7 @@ public abstract class BaseOutboundSetting
|
||||
/// <summary>
|
||||
/// 出站代理协议类型.
|
||||
/// </summary>
|
||||
public required OutboundProtocolType Protocol { get; init; }
|
||||
public OutboundProtocolType Protocol { get; init; }
|
||||
|
||||
public BaseStreamSetting StreamSetting { get; init; } = new RawStreamSetting();
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class BaseOutboundSetting
|
||||
/// 生成对应的 OutboundObject JSON 配置.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public JsonObject ToJsonSetting()
|
||||
public virtual JsonObject ToJsonSetting()
|
||||
{
|
||||
var root = new JsonObject
|
||||
{
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace Proxd_man.Config.Outbound;
|
||||
|
||||
public class BlackholeOutboundSetting : BaseOutboundSetting
|
||||
{
|
||||
|
||||
private readonly string _tag;
|
||||
|
||||
public BlackholeOutboundSetting(string tag = "block")
|
||||
{
|
||||
Protocol = OutboundProtocolType.Blackhole;
|
||||
this._tag = tag;
|
||||
}
|
||||
|
||||
public override JsonObject ToJsonSetting()
|
||||
{
|
||||
return new JsonObject
|
||||
{
|
||||
{ "protocol", "freedom" },
|
||||
{ "tag", _tag }
|
||||
};
|
||||
}
|
||||
|
||||
public override string GetTag()
|
||||
{
|
||||
return _tag;
|
||||
}
|
||||
|
||||
protected override JsonObject GetProtocolSetting()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace Proxd_man.Config.Outbound;
|
||||
|
||||
public class FreedomOutboundSetting : BaseOutboundSetting
|
||||
{
|
||||
|
||||
private readonly string _tag;
|
||||
|
||||
public FreedomOutboundSetting(string tag = "direct")
|
||||
{
|
||||
Protocol = OutboundProtocolType.Freedom;
|
||||
this._tag = tag;
|
||||
}
|
||||
|
||||
public override JsonObject ToJsonSetting()
|
||||
{
|
||||
return new JsonObject
|
||||
{
|
||||
{ "protocol", "freedom" },
|
||||
{ "tag", _tag }
|
||||
};
|
||||
}
|
||||
|
||||
public override string GetTag()
|
||||
{
|
||||
return _tag;
|
||||
}
|
||||
|
||||
protected override JsonObject GetProtocolSetting()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,11 @@ public class ShadowSocksOutboundSetting : BaseOutboundSetting
|
||||
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()
|
||||
{
|
||||
@@ -27,13 +32,15 @@ public class ShadowSocksOutboundSetting : BaseOutboundSetting
|
||||
{
|
||||
var root = new JsonObject();
|
||||
|
||||
var setting = new JsonObject();
|
||||
setting.Add("address", Address);
|
||||
setting.Add("port", Port);
|
||||
setting.Add("method", Method);
|
||||
setting.Add("password", Password);
|
||||
var setting = new JsonObject
|
||||
{
|
||||
{ "address", Address },
|
||||
{ "port", Port },
|
||||
{ "method", Method },
|
||||
{ "password", Password },
|
||||
{ "uot", EnableUdpOverTcp }
|
||||
};
|
||||
|
||||
setting.Add("uot", EnableUdpOverTcp);
|
||||
if (EnableUdpOverTcp)
|
||||
{
|
||||
setting.Add("UoTVersion", UdpOverTcpVersion);
|
||||
|
||||
Reference in New Issue
Block a user