pub struct Config {Show 28 fields
pub server: Vec<ServerInstanceConfig>,
pub local: Vec<LocalInstanceConfig>,
pub dns: DnsConfig,
pub dns_cache_size: Option<usize>,
pub ipv6_first: bool,
pub ipv6_only: bool,
pub no_delay: bool,
pub fast_open: bool,
pub keep_alive: Option<Duration>,
pub mptcp: bool,
pub nofile: Option<u64>,
pub outbound_fwmark: Option<u32>,
pub outbound_bind_interface: Option<String>,
pub outbound_bind_addr: Option<IpAddr>,
pub outbound_udp_allow_fragmentation: bool,
pub inbound_send_buffer_size: Option<u32>,
pub inbound_recv_buffer_size: Option<u32>,
pub outbound_send_buffer_size: Option<u32>,
pub outbound_recv_buffer_size: Option<u32>,
pub manager: Option<ManagerConfig>,
pub config_type: ConfigType,
pub udp_timeout: Option<Duration>,
pub udp_max_associations: Option<usize>,
pub udp_mtu: Option<usize>,
pub acl: Option<AccessControl>,
pub security: SecurityConfig,
pub balancer: BalancerConfig,
pub config_path: Option<PathBuf>,
}Expand description
Configuration
Fields§
§server: Vec<ServerInstanceConfig>Remote ShadowSocks server configurations
local: Vec<LocalInstanceConfig>Local server configuration
dns: DnsConfigDNS configuration, uses system-wide DNS configuration by default
Value could be a IpAddr, uses UDP DNS protocol with port 53. For example: 8.8.8.8
Also Value could be some pre-defined DNS server names:
googlecloudflare,cloudflare_tls,cloudflare_httpsquad9,quad9_tls
dns_cache_size: Option<usize>§ipv6_first: boolUses IPv6 addresses first
Set to true if you want to query IPv6 addresses before IPv4
ipv6_only: boolSet IPV6_V6ONLY for listener sockets
no_delay: boolSet TCP_NODELAY socket option
fast_open: boolSet TCP_FASTOPEN socket option
keep_alive: Option<Duration>Set TCP Keep-Alive duration, will set both TCP_KEEPIDLE and TCP_KEEPINTVL
https://github.com/shadowsocks/shadowsocks-rust/issues/546
If this is not set, sockets will be set with a default timeout
mptcp: boolMultipath-TCP
nofile: Option<u64>RLIMIT_NOFILE option for *nix systems
outbound_fwmark: Option<u32>Set SO_MARK socket option for outbound sockets
outbound_bind_interface: Option<String>Set SO_BINDTODEVICE (Linux), IP_BOUND_IF (BSD), IP_UNICAST_IF (Windows) socket option for outbound sockets
outbound_bind_addr: Option<IpAddr>Outbound sockets will bind to this address
outbound_udp_allow_fragmentation: boolOutbound UDP sockets allow IP fragmentation
inbound_send_buffer_size: Option<u32>Set SO_SNDBUF for inbound sockets
inbound_recv_buffer_size: Option<u32>Set SO_RCVBUF for inbound sockets
outbound_send_buffer_size: Option<u32>Set SO_SNDBUF for outbound sockets
outbound_recv_buffer_size: Option<u32>Set SO_RCVBUF for outbound sockets
manager: Option<ManagerConfig>Manager’s configuration
config_type: ConfigTypeConfig is for Client or Server
udp_timeout: Option<Duration>Timeout for UDP Associations, default is 5 minutes
udp_max_associations: Option<usize>Maximum number of UDP Associations, default is unconfigured
udp_mtu: Option<usize>Maximum Transmission Unit (MTU) size for UDP packets 65535 by default. Suggestion: 1500 NOTE: mtu includes IP header, UDP header, UDP payload
acl: Option<AccessControl>ACL configuration (Global)
Could be overwritten by servers/locals’ private acl
security: SecurityConfigReplay attack policy
balancer: BalancerConfigBalancer config of local server
config_path: Option<PathBuf>Configuration file path, the actual path of the configuration. This is normally for auto-reloading if implementation supports.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(config_type: ConfigType) -> Self
pub fn new(config_type: ConfigType) -> Self
Creates an empty configuration
Sourcepub fn set_dns_formatted(&mut self, dns: &str) -> Result<(), Error>
pub fn set_dns_formatted(&mut self, dns: &str) -> Result<(), Error>
Set DNS configuration in string format
[(unix|tcp|udp)://]host[:port][,host[:port]]...- Pre-defined. Like
google,cloudflare
Sourcepub fn load_from_str(s: &str, config_type: ConfigType) -> Result<Self, Error>
pub fn load_from_str(s: &str, config_type: ConfigType) -> Result<Self, Error>
Load Config from a str
Sourcepub fn load_from_json_str(
s: &str,
config_type: ConfigType,
) -> Result<Self, Error>
pub fn load_from_json_str( s: &str, config_type: ConfigType, ) -> Result<Self, Error>
Load Config from a JSON str
Sourcepub fn load_from_file<P: AsRef<Path>>(
filename: P,
config_type: ConfigType,
) -> Result<Self, Error>
pub fn load_from_file<P: AsRef<Path>>( filename: P, config_type: ConfigType, ) -> Result<Self, Error>
Load Config from a File
Sourcepub fn has_server_plugins(&self) -> bool
pub fn has_server_plugins(&self) -> bool
Check if there are any plugin are enabled with servers
Sourcepub fn check_integrity(&self) -> Result<(), Error>
pub fn check_integrity(&self) -> Result<(), Error>
Check if all required fields are already set