feat: 实现依据 InboundSetting 和 OutboundSetting 生成配置的功能.

This commit is contained in:
2025-01-10 10:00:56 +08:00
parent db43e05770
commit f802695f39
5 changed files with 247 additions and 49 deletions
@@ -20,11 +20,13 @@ public abstract class BaseOutboundSetting
/// <summary>
/// 发送出站数据所使用的网卡地址.
/// </summary>
public string BindAddress { get; init; } = "0.0.0.0";
public string? BindAddress { get; init; }
/// <summary>
/// 出站代理协议类型.
/// </summary>
public OutboundProtocolType Protocol { get; init; }
public string? Address { get; init; }
public BaseStreamSetting StreamSetting { get; init; } = new RawStreamSetting();
@@ -41,12 +43,16 @@ public abstract class BaseOutboundSetting
{
var root = new JsonObject
{
{ "sendThrough", BindAddress },
{ "protocol", Protocol.ToString().ToLower() },
{ "tag", GetTag() },
{ "settings", GetProtocolSetting() }
};
if (!string.IsNullOrEmpty(BindAddress))
{
root.Add("sendThrough", BindAddress);
}
if (!string.IsNullOrEmpty(NextOutboundTag))
{
root.Add("proxySettings", new JsonObject
@@ -12,7 +12,7 @@ public class ShadowSocksOutboundSetting : BaseOutboundSetting
public string? UserEmail { get; init; } = null;
public required string Method { get; init; }
public required string Address { get; init; }
public new required string Address { get; init; }
public int Port { get; init; }
public required string Password { get; init; }
public bool EnableUdpOverTcp { get; init; } = false;