Config

Struct Config 

Source
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: DnsConfig

DNS 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:

  • google
  • cloudflare, cloudflare_tls, cloudflare_https
  • quad9, quad9_tls
§dns_cache_size: Option<usize>§ipv6_first: bool

Uses IPv6 addresses first

Set to true if you want to query IPv6 addresses before IPv4

§ipv6_only: bool

Set IPV6_V6ONLY for listener sockets

§no_delay: bool

Set TCP_NODELAY socket option

§fast_open: bool

Set 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: bool

Multipath-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: bool

Outbound 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: ConfigType

Config 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: SecurityConfig

Replay attack policy

§balancer: BalancerConfig

Balancer 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

Source

pub fn new(config_type: ConfigType) -> Self

Creates an empty configuration

Source

pub fn set_dns_formatted(&mut self, dns: &str) -> Result<(), Error>

Set DNS configuration in string format

  1. [(unix|tcp|udp)://]host[:port][,host[:port]]...
  2. Pre-defined. Like google, cloudflare
Source

pub fn load_from_str(s: &str, config_type: ConfigType) -> Result<Self, Error>

Load Config from a str

Source

pub fn load_from_json_str( s: &str, config_type: ConfigType, ) -> Result<Self, Error>

Load Config from a JSON str

Source

pub fn load_from_file<P: AsRef<Path>>( filename: P, config_type: ConfigType, ) -> Result<Self, Error>

Load Config from a File

Source

pub fn has_server_plugins(&self) -> bool

Check if there are any plugin are enabled with servers

Source

pub fn check_integrity(&self) -> Result<(), Error>

Check if all required fields are already set

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more