yamux

Struct Config

Source
pub struct Config { /* private fields */ }
Expand description

Yamux configuration.

The default configuration values are as follows:

  • max. for the total receive window size across all streams of a connection = 1 GiB
  • max. number of streams = 512
  • read after close = true
  • split send size = 16 KiB

Implementations§

Source§

impl Config

Source

pub fn set_max_connection_receive_window( &mut self, n: Option<usize>, ) -> &mut Self

Set the upper limit for the total receive window size across all streams of a connection.

Must be >= 256 KiB * max_num_streams to allow each stream at least the Yamux default window size.

The window of a stream starts at 256 KiB and is increased (auto-tuned) based on the connection’s round-trip time and the stream’s bandwidth (striving for the bandwidth-delay-product).

Set to None to disable limit, i.e. allow each stream to grow receive window based on connection’s round-trip time and stream’s bandwidth without limit.

§DOS attack mitigation

A remote node (attacker) might trick the local node (target) into allocating large stream receive windows, trying to make the local node run out of memory.

This attack is difficult, as the local node only increases the stream receive window up to 2x the bandwidth-delay-product, where bandwidth is the amount of bytes read, not just received. In other words, the attacker has to send (and have the local node read) significant amount of bytes on a stream over a long period of time to increase the stream receive window. E.g. on a 60ms 10Gbit/s connection the bandwidth-delay-product is ~75 MiB and thus the local node will at most allocate ~150 MiB (2x bandwidth-delay-product) per stream.

Despite the difficulty of the attack one should choose a reasonable max_connection_receive_window to protect against this attack, especially since an attacker might use more than one stream per connection.

Source

pub fn set_max_num_streams(&mut self, n: usize) -> &mut Self

Set the max. number of streams per connection.

Source

pub fn set_read_after_close(&mut self, b: bool) -> &mut Self

Allow or disallow streams to read from buffered data after the connection has been closed.

Source

pub fn set_split_send_size(&mut self, n: usize) -> &mut Self

Set the max. payload size used when sending data frames. Payloads larger than the configured max. will be split.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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 Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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, 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