refactor: 调整一些配置的设定形式.
This commit is contained in:
@@ -4,31 +4,34 @@ namespace Proxd_man.Config;
|
||||
|
||||
public class ProxdConfig
|
||||
{
|
||||
public InboundConfig Inbound { get; init; } = new(new HttpInboundSetting());
|
||||
public InboundConfig Inbounds { get; init; } = new();
|
||||
public DefaultOutboundPolicy DefaultOutboundPolicy { get; init; } = DefaultOutboundPolicy.Proxy;
|
||||
public string RemoteDnsServer { get; init; } = "https://1.1.1.1/dns-query";
|
||||
public string XrayCoreProgramDirectory { get; init; } = "./xray-core";
|
||||
public string XrayCoreWorkingDirectory { get; init; } = "./xray-core";
|
||||
public SubscribeSetting Subscribe { get; init; } = new();
|
||||
}
|
||||
|
||||
public class InboundConfig(HttpInboundSetting? http = null, SocksInboundSetting? socks = null)
|
||||
public class InboundConfig
|
||||
{
|
||||
public HttpInboundSetting? Http { get; } = http;
|
||||
public SocksInboundSetting? Socks { get; } = socks;
|
||||
public HttpInboundSetting? Http { get; init; }
|
||||
public SocksInboundSetting? Socks { get; init; }
|
||||
}
|
||||
|
||||
public interface IInboundSetting
|
||||
{
|
||||
JsonObject ToJsonSetting();
|
||||
|
||||
string GetTag();
|
||||
|
||||
}
|
||||
|
||||
public class HttpInboundSetting(
|
||||
string? bindAddress = null,
|
||||
ushort port = 1080,
|
||||
BasicInboundAuthSetting? authentication = null) : IInboundSetting
|
||||
public class HttpInboundSetting : IInboundSetting
|
||||
{
|
||||
public string? BindAddress { get; } = bindAddress;
|
||||
public ushort Port = port;
|
||||
public string? BindAddress { get; init; }
|
||||
public ushort Port { get; init; }
|
||||
|
||||
public BasicInboundAuthSetting? Authentication { get; } = authentication;
|
||||
public BasicInboundAuthSetting? Authentication { get; init; }
|
||||
|
||||
public JsonObject ToJsonSetting()
|
||||
{
|
||||
@@ -37,7 +40,7 @@ public class HttpInboundSetting(
|
||||
{ "protocol", "http" },
|
||||
{ "listen", $"{BindAddress ?? "0.0.0.0"}" },
|
||||
{ "port", Port },
|
||||
{ "tag", "http-in" },
|
||||
{ "tag", GetTag() },
|
||||
{
|
||||
"sniffing", new JsonObject
|
||||
{
|
||||
@@ -65,30 +68,30 @@ public class HttpInboundSetting(
|
||||
|
||||
return setting;
|
||||
}
|
||||
|
||||
public string GetTag()
|
||||
{
|
||||
return "http-in";
|
||||
}
|
||||
}
|
||||
|
||||
public class SocksInboundSetting(
|
||||
string? bindAddress = null,
|
||||
ushort port = 1080,
|
||||
bool enableUdp = true,
|
||||
string? bindAddressOnUdp = "127.0.0.1",
|
||||
BasicInboundAuthSetting? authentication = null) : IInboundSetting
|
||||
public class SocksInboundSetting : IInboundSetting
|
||||
{
|
||||
public string? BindAddress { get; } = bindAddress;
|
||||
public ushort Port = port;
|
||||
public string? BindAddress { get; init; }
|
||||
public ushort Port { get; init; }
|
||||
|
||||
public bool EnableUdp { get; } = enableUdp;
|
||||
public string? BindAddressOnUdp { get; } = bindAddressOnUdp;
|
||||
public BasicInboundAuthSetting? Authentication { get; } = authentication;
|
||||
public bool EnableUdp { get; init; }
|
||||
public string? BindAddressOnUdp { get; init; }
|
||||
public BasicInboundAuthSetting? Authentication { get; init; }
|
||||
|
||||
public JsonObject ToJsonSetting()
|
||||
{
|
||||
JsonObject setting = new()
|
||||
{
|
||||
{ "protocol", "http" },
|
||||
{ "protocol", "socks" },
|
||||
{ "listen", $"{BindAddress ?? "0.0.0.0"}" },
|
||||
{ "port", Port },
|
||||
{ "tag", "http-in" },
|
||||
{ "tag", GetTag() },
|
||||
{
|
||||
"sniffing", new JsonObject
|
||||
{
|
||||
@@ -123,7 +126,11 @@ public class SocksInboundSetting(
|
||||
setting.Add("settings", settingJson);
|
||||
return setting;
|
||||
}
|
||||
|
||||
|
||||
public string GetTag()
|
||||
{
|
||||
return "socks-in";
|
||||
}
|
||||
}
|
||||
|
||||
public class BasicInboundAuthSetting(string username, string password)
|
||||
|
||||
Reference in New Issue
Block a user