using System.Collections.Generic; using System.Text.Json.Serialization; using Netch.Utils; namespace Netch.Models { /// /// TUN/TAP 适配器配置类 /// public class TUNConfig { /// /// 地址 /// public string Address { get; set; } = "10.0.236.10"; /// /// DNS /// public string HijackDNS { get; set; } = "tcp://1.1.1.1:53"; /// /// 网关 /// public string Gateway { get; set; } = "10.0.236.1"; /// /// 掩码 /// public string Netmask { get; set; } = "255.255.255.0"; /// /// 模式 2 下是否代理 DNS /// public bool ProxyDNS { get; set; } = false; /// /// 使用自定义 DNS 设置 /// public bool UseCustomDNS { get; set; } = true; /// /// 全局绕过 IP 列表 /// public List BypassIPs { get; set; } = new(); } public class KcpConfig { public bool congestion { get; set; } = false; public int downlinkCapacity { get; set; } = 100; public int mtu { get; set; } = 1350; public int readBufferSize { get; set; } = 2; public int tti { get; set; } = 50; public int uplinkCapacity { get; set; } = 12; public int writeBufferSize { get; set; } = 2; } public class V2rayConfig { public bool AllowInsecure { get; set; } = false; public KcpConfig KcpConfig { get; set; } = new(); public bool UseMux { get; set; } = false; public bool V2rayNShareLink { get; set; } = true; public bool XrayCone { get; set; } = false; } public class AioDNSConfig { public string ChinaDNS { get; set; } = "tcp://223.5.5.5:53"; public string OtherDNS { get; set; } = "tcp://1.1.1.1:53"; public ushort ListenPort { get; set; } = 253; } public class RedirectorConfig { /// /// 不代理TCP /// public PortType FilterProtocol { get; set; } = PortType.Both; /// /// 是否开启DNS转发 /// public bool DNSHijack { get; set; } = true; /// /// 转发DNS地址 /// public string DNSHijackHost { get; set; } = "1.1.1.1:53"; [JsonIgnore] public int ICMPDelay { get; } = 0; public bool FilterICMP { get; set; } = false; /// /// 是否代理子进程 /// public bool ChildProcessHandle { get; set; } = false; } /// /// 用于读取和写入的配置的类 /// public class Setting { public RedirectorConfig Redirector { get; set; } = new(); /// /// 服务器列表 /// public List Server { get; set; } = new(); public AioDNSConfig AioDNS { get; set; } = new(); /// /// 是否检查 Beta 更新 /// public bool CheckBetaUpdate { get; set; } = false; /// /// 是否打开软件时检查更新 /// public bool CheckUpdateWhenOpened { get; set; } = true; /// /// 测试所有服务器心跳/秒 /// public int DetectionTick { get; set; } = 10; /// /// 是否关闭窗口时退出 /// public bool ExitWhenClosed { get; set; } = false; /// /// HTTP 本地端口 /// public ushort HTTPLocalPort { get; set; } = 2802; /// /// 语言设置 /// public string Language { get; set; } = "System"; /// /// HTTP 和 Socks5 本地代理地址 /// public string LocalAddress { get; set; } = "127.0.0.1"; /// /// 是否启动后自动最小化 /// public bool MinimizeWhenStarted { get; set; } = false; /// /// 模式选择位置 /// public int ModeComboBoxSelectedIndex { get; set; } = -1; /// /// 快捷配置数量 /// public int ProfileCount { get; set; } = 4; /// /// 已保存的快捷配置 /// public List Profiles { get; set; } = new(); /// /// 配置最大列数 /// public byte ProfileTableColumnCount { get; set; } = 5; /// /// 网页请求超时 毫秒 /// public int RequestTimeout { get; set; } = 10000; /// /// 解析服务器主机名 /// public bool ResolveServerHostname { get; set; } = true; /// /// 是否开机启动软件 /// public bool RunAtStartup { get; set; } = false; /// /// 服务器选择位置 /// public int ServerComboBoxSelectedIndex { get; set; } = -1; /// /// 服务器测试方式 false.ICMPing true.TCPing /// public bool ServerTCPing { get; set; } = true; /// /// Socks5 本地端口 /// public ushort Socks5LocalPort { get; set; } = 2801; /// /// 启动后延迟测试间隔/秒 /// public int StartedPingInterval { get; set; } = -1; /// /// 是否打开软件时启动加速 /// public bool StartWhenOpened { get; set; } = false; /// /// 是否退出时停止 /// public bool StopWhenExited { get; set; } = false; /// /// STUN测试服务器 /// public string STUN_Server { get; set; } = "stun.syncthing.net"; /// /// STUN测试服务器 /// public int STUN_Server_Port { get; set; } = 3478; /// /// 订阅链接列表 /// public List SubscribeLink { get; set; } = new(); /// /// TUNTAP 适配器配置 /// public TUNConfig TUNTAP { get; set; } = new(); /// /// 是否打开软件时更新订阅 /// public bool UpdateServersWhenOpened { get; set; } = false; public V2rayConfig V2RayConfig { get; set; } = new(); public bool NoSupportDialog { get; set; } = false; public Setting Clone() { return (Setting)MemberwiseClone(); } public void Set(Setting value) { foreach (var p in typeof(Setting).GetProperties()) p.SetValue(this, p.GetValue(value)); } } }