pub struct ServerConfig { /* private fields */ }
Expand description

Configuration for a server

Implementations§

source§

impl ServerConfig

source

pub fn new<A, P>(addr: A, password: P, method: CipherKind) -> ServerConfig
where A: Into<ServerAddr>, P: Into<String>,

Create a new ServerConfig

source

pub fn set_method<P>(&mut self, method: CipherKind, password: P)
where P: Into<String>,

Set encryption method

source

pub fn set_plugin(&mut self, p: PluginConfig)

Set plugin

source

pub fn set_addr<A>(&mut self, a: A)
where A: Into<ServerAddr>,

Set server addr

source

pub fn addr(&self) -> &ServerAddr

Get server address

source

pub fn key(&self) -> &[u8]

Get encryption key

source

pub fn password(&self) -> &str

Get password

source

pub fn identity_keys(&self) -> &[Bytes]

Get identity keys (Client)

source

pub fn clone_identity_keys(&self) -> Arc<Vec<Bytes>>

Clone identity keys (Client)

source

pub fn set_user_manager(&mut self, user_manager: ServerUserManager)

Set user manager, enable Server’s multi-user support with EIH

source

pub fn user_manager(&self) -> Option<&ServerUserManager>

Get user manager (Server)

source

pub fn clone_user_manager(&self) -> Option<Arc<ServerUserManager>>

Clone user manager (Server)

source

pub fn method(&self) -> CipherKind

Get method

source

pub fn plugin(&self) -> Option<&PluginConfig>

Get plugin

source

pub fn set_plugin_addr(&mut self, a: ServerAddr)

Set plugin address

source

pub fn plugin_addr(&self) -> Option<&ServerAddr>

Get plugin address

source

pub fn tcp_external_addr(&self) -> &ServerAddr

Get server’s TCP external address

source

pub fn udp_external_addr(&self) -> &ServerAddr

Get server’s UDP external address

source

pub fn set_timeout(&mut self, timeout: Duration)

Set timeout

source

pub fn timeout(&self) -> Option<Duration>

Timeout

source

pub fn remarks(&self) -> Option<&str>

Get server’s remark

source

pub fn set_remarks<S>(&mut self, remarks: S)
where S: Into<String>,

Set server’s remark

source

pub fn id(&self) -> Option<&str>

Get server’s ID (SIP008)

source

pub fn set_id<S>(&mut self, id: S)
where S: Into<String>,

Set server’s ID (SIP008)

source

pub fn mode(&self) -> Mode

Get server’s Mode

source

pub fn set_mode(&mut self, mode: Mode)

Set server’s Mode

source

pub fn weight(&self) -> &ServerWeight

Get server’s balancer weight

source

pub fn set_weight(&mut self, weight: ServerWeight)

Set server’s balancer weight

source

pub fn to_qrcode_url(&self) -> String

Get URL for QRCode

ss:// + base64(method:password@host:port)
source

pub fn to_url(&self) -> String

Get SIP002 URL

source

pub fn from_url(encoded: &str) -> Result<ServerConfig, UrlParseError>

Parse from SIP002 URL

Extended formats:

  1. QRCode URL supported by shadowsocks-android, https://github.com/shadowsocks/shadowsocks-android/issues/51
  2. Plain userinfo:password format supported by go2-shadowsocks2
source

pub fn is_basic(&self) -> bool

Check if it is a basic format server

Trait Implementations§

source§

impl Clone for ServerConfig

source§

fn clone(&self) -> ServerConfig

Returns a copy 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 ServerConfig

source§

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

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

impl FromStr for ServerConfig

§

type Err = UrlParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<ServerConfig, Self::Err>

Parses a string s to return a value of this type. Read more

Auto Trait Implementations§

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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