Struct libp2p_tcp::Config
source · pub struct Config { /* private fields */ }
Expand description
The configuration for a TCP/IP transport capability for libp2p.
Implementations§
source§impl Config
impl Config
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new configuration for a TCP/IP transport:
- Nagle’s algorithm, i.e.
TCP_NODELAY
, is enabled. SeeConfig::nodelay
. - Reuse of listening ports is disabled.
See
Config::port_reuse
. - No custom
IP_TTL
is set. The default of the OS TCP stack applies. SeeConfig::ttl
. - The size of the listen backlog for new listening sockets is
1024
. SeeConfig::listen_backlog
.
sourcepub fn listen_backlog(self, backlog: u32) -> Self
pub fn listen_backlog(self, backlog: u32) -> Self
Configures the listen backlog for new listen sockets.
sourcepub fn port_reuse(self, _port_reuse: bool) -> Self
👎Deprecated since 0.42.0: This option does nothing now, since the port reuse policy is now decided on a per-connection basis by the behaviour. The function will be removed in a future release.
pub fn port_reuse(self, _port_reuse: bool) -> Self
Configures port reuse for local sockets, which implies reuse of listening ports for outgoing connections to enhance NAT traversal capabilities.
§Deprecation Notice
The new implementation works on a per-connaction basis, defined by the behaviour. This removes the necessaity to configure the transport for port reuse, instead the behaviour requiring this behaviour can decide wether to use port reuse or not.
The API to configure port reuse is part of Transport
and the option can be found in
libp2p_core::transport::DialOpts
.
If PortUse::Reuse
is enabled, the transport will try to reuse the local port of the
listener. If that’s not possible, i.e. there is no listener or the transport doesn’t allow
a direct control over ports, a new port (or the default behaviour) is used. If port reuse
is enabled for a connection, this option will be treated on a best-effor basis.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more