Config

Struct Config 

Source
pub struct Config {
    pub WGPROXY_SERVER: String,
    pub WGPROXY_PUBKEY: [u8; 32],
    pub WGPROXY_LISTEN: SocketAddr,
    pub WGPROXY_TIMEOUT: Duration,
    pub WGPROXY_LOGLEVEL: u8,
}
Expand description

The server config

Fields§

§WGPROXY_SERVER: String

The server address to forward the traffic to

§Example

An address:port combination

§WGPROXY_PUBKEY: [u8; 32]

The server public key for handshake validation

§Note

The public key is used for handshake verfication and quick rejection when a new proxy connection is created. This is a security feature to ensure that the relay will not forward arbitrary rogue packets. If the handshake does not match the configured public key, the packet will be dropped.

§WGPROXY_LISTEN: SocketAddr

The address to listen on and to use for relaying

§Example

An inclusive range of ports, defaults to Self::WGPROXY_LISTEN_DEFAULT

§WGPROXY_TIMEOUT: Duration

The timeout duration for NAT mappings to expire

§Example

A duration in seconds, defaults to Self::WGPROXY_TIMEOUT_DEFAULT

§WGPROXY_LOGLEVEL: u8

The log level

§Possible Values

Possible values are:

  • 0: Logs errors only
  • 1: Logs warnings and errors
  • 2: Logs informational messages, warnings, and errors
  • 3: Logs debug and informational messages, warnings, and errors

§Example

A positive integer value, defaults to Self::WGPROXY_LOGLEVEL_DEFAULT

Implementations§

Source§

impl Config

Source

pub const WGPROXY_LISTEN_DEFAULT: &str = "[::]:51820"

The default listening address if Self::WGPROXY_LISTEN is not specified

Source

pub const WGPROXY_TIMEOUT_DEFAULT: &str = "60"

The default timeout in seconds if Self::WGPROXY_TIMEOUT is not specified

Source

pub const WGPROXY_LOGLEVEL_DEFAULT: &str = "1"

The default loglevel if Self::WGPROXY_LOGLEVEL is not specified

Source

pub fn from_env() -> Result<Self, Error>

Gets the config from the environment

Source

pub fn wgproxy_loglevel() -> Result<u8, Error>

Parses the WGPROXY_LOGLEVEL environment variable, or falls back to Self::WGPROXY_LOGLEVEL_DEFAULT

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

impl Loggable for &Config

Source§

fn write(&self, sink: &mut dyn Write) -> Result<(), Error>

Formats self and writes it to the given sink
Source§

fn log(self, severity: u8) -> Self

Converts a severity level to a logging prefix
Source§

fn skip(&self) -> bool

If logging self should be skipped or not

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

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.