using Shadowsocks.Models; using System.Collections.Generic; using System.Text.Json.Serialization; namespace Shadowsocks.Interop.SsRust { public class Config : IGroup { /// public int Version { get; set; } /// public List Servers { get; set; } /// /// Gets or sets the listening address. /// public string LocalAddress { get; set; } /// /// Gets or sets the listening port. /// public int LocalPort { get; set; } /// [JsonPropertyName("server")] public string? Host { get; set; } /// [JsonPropertyName("server_port")] public int Port { get; set; } /// public string? Password { get; set; } /// public string? Method { get; set; } /// public string? Plugin { get; set; } /// public string? PluginOpts { get; set; } /// public List? PluginArgs { get; set; } /// /// Gets or sets the timeout for UDP associations in seconds. /// Defaults to 300 seconds (5 minutes). /// public int? UdpTimeout { get; set; } /// /// Gets or sets the maximum number of UDP associations. /// Defaults to 0 (unlimited). /// public int UdpMaxAssociations { get; set; } /// /// Gets or sets the server manager address. /// public string? ManagerAddress { get; set; } /// /// Gets or sets the server manager port. /// public int ManagerPort { get; set; } /// /// Gets or sets the DNS server used to resolve hostnames. /// public string? Dns { get; set; } /// /// Gets or sets the mode. /// Defaults to tcp_only. /// Can also be tcp_and_udp or udp_only. /// public string Mode { get; set; } /// /// Gets or sets TCP_NODELAY. /// Defaults to false. /// public bool NoDelay { get; set; } /// /// Gets or sets the soft and hard limit of file descriptors. /// public int Nofile { get; set; } /// /// Gets or sets whether IPv6 addresses take precedence over IPv4 addresses for resolved hostnames. /// Defaults to false. /// public bool Ipv6First { get; set; } public Config() { Version = 1; Servers = new(); LocalAddress = ""; LocalPort = 1080; Mode = "tcp_only"; } /// /// Gets the default configuration for Linux. /// public static Config DefaultLinux => new() { LocalAddress = "::1", Mode = "tcp_and_udp", NoDelay = true, Nofile = 32768, Ipv6First = true, }; /// /// Gets the default configuration for Windows. /// public static Config DefaultWindows => new() { LocalAddress = "::1", Mode = "tcp_and_udp", NoDelay = true, Ipv6First = true, }; } }