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