Struct libp2p_websocket::WsConfig
source · pub struct WsConfig<T> { /* private fields */ }
Expand description
Represents the configuration for a websocket transport capability for libp2p. Must be put on
top of another Transport
.
This implementation of Transport
accepts any address that ends with /ws
or /wss
, and will
try to pass the underlying multiaddress to the underlying Transport
.
Note that the underlying multiaddr is /dns4/...
or /dns6/...
, then this library will
pass the domain name in the headers of the request. This is important is the listener is behind
an HTTP proxy.
Note:
/wss
is only supported for dialing and not listening.
Implementations
Trait Implementations
sourceimpl<T> Transport for WsConfig<T>where
T: Transport + 'static,
T::Error: Send,
T::Dial: Send,
T::Listener: Send,
T::ListenerUpgrade: Send,
T::Output: AsyncRead + AsyncWrite + Send,
impl<T> Transport for WsConfig<T>where
T: Transport + 'static,
T::Error: Send,
T::Dial: Send,
T::Listener: Send,
T::ListenerUpgrade: Send,
T::Output: AsyncRead + AsyncWrite + Send,
type Listener = Box<dyn Stream<Item = (<WsConfig<T> as Transport>::ListenerUpgrade, Multiaddr), Error = <WsConfig<T> as Transport>::Error> + Send + 'static, Global>
type Listener = Box<dyn Stream<Item = (<WsConfig<T> as Transport>::ListenerUpgrade, Multiaddr), Error = <WsConfig<T> as Transport>::Error> + Send + 'static, Global>
The listener produces incoming connections. Read more
type ListenerUpgrade = Box<dyn Future<Item = <WsConfig<T> as Transport>::Output, Error = <WsConfig<T> as Transport>::Error> + Send + 'static, Global>
type ListenerUpgrade = Box<dyn Future<Item = <WsConfig<T> as Transport>::Output, Error = <WsConfig<T> as Transport>::Error> + Send + 'static, Global>
After a connection has been received, we may need to do some asynchronous pre-processing
on it (e.g. an intermediary protocol negotiation). While this pre-processing takes place,
we want to be able to continue polling on the listener. Read more
type Dial = Box<dyn Future<Item = <WsConfig<T> as Transport>::Output, Error = <WsConfig<T> as Transport>::Error> + Send + 'static, Global>
type Dial = Box<dyn Future<Item = <WsConfig<T> as Transport>::Output, Error = <WsConfig<T> as Transport>::Error> + Send + 'static, Global>
A future which indicates that we are currently dialing to a peer.
sourcefn listen_on(
self,
original_addr: Multiaddr
) -> Result<(Self::Listener, Multiaddr), TransportError<Self::Error>>
fn listen_on(
self,
original_addr: Multiaddr
) -> Result<(Self::Listener, Multiaddr), TransportError<Self::Error>>
Listen on the given multiaddr. Returns a stream of incoming connections, plus a modified
version of the
Multiaddr
. This new Multiaddr
is the one that that should be advertised
to other nodes, instead of the one passed as parameter. Read moresourcefn dial(
self,
original_addr: Multiaddr
) -> Result<Self::Dial, TransportError<Self::Error>>
fn dial(
self,
original_addr: Multiaddr
) -> Result<Self::Dial, TransportError<Self::Error>>
Dial the given multi-addr. Read more
sourcefn nat_traversal(
&self,
server: &Multiaddr,
observed: &Multiaddr
) -> Option<Multiaddr>
fn nat_traversal(
&self,
server: &Multiaddr,
observed: &Multiaddr
) -> Option<Multiaddr>
Takes a multiaddress we’re listening on (
server
), and tries to convert it to an
externally-visible multiaddress. In order to do so, we pass an observed
address which
a remote node observes for one of our dialers. Read moresourcefn map<F, O>(self, map: F) -> Map<Self, F>where
Self: Sized,
F: FnOnce(Self::Output, ConnectedPoint) -> O + Clone,
fn map<F, O>(self, map: F) -> Map<Self, F>where
Self: Sized,
F: FnOnce(Self::Output, ConnectedPoint) -> O + Clone,
Applies a function on the output of the
Transport
.sourcefn map_err<F, TNewErr>(self, map_err: F) -> MapErr<Self, F>where
Self: Sized,
F: FnOnce(Self::Error) -> TNewErr + Clone,
fn map_err<F, TNewErr>(self, map_err: F) -> MapErr<Self, F>where
Self: Sized,
F: FnOnce(Self::Error) -> TNewErr + Clone,
Applies a function on the errors generated by the futures of the
Transport
.sourcefn or_transport<T>(self, other: T) -> OrTransport<Self, T>where
Self: Sized,
fn or_transport<T>(self, other: T) -> OrTransport<Self, T>where
Self: Sized,
sourcefn and_then<C, F, O>(self, upgrade: C) -> AndThen<Self, C>where
Self: Sized,
C: FnOnce(Self::Output, ConnectedPoint) -> F + Clone,
F: IntoFuture<Item = O>,
fn and_then<C, F, O>(self, upgrade: C) -> AndThen<Self, C>where
Self: Sized,
C: FnOnce(Self::Output, ConnectedPoint) -> F + Clone,
F: IntoFuture<Item = O>,
Wraps this transport inside an upgrade. Whenever a connection that uses this transport
is established, it is wrapped inside the upgrade. Read more
sourcefn with_timeout(self, timeout: Duration) -> TransportTimeout<Self>where
Self: Sized,
fn with_timeout(self, timeout: Duration) -> TransportTimeout<Self>where
Self: Sized,
Adds a timeout to the connection and upgrade steps for all the sockets created by
the transport. Read more
sourcefn with_outbound_timeout(self, timeout: Duration) -> TransportTimeout<Self>where
Self: Sized,
fn with_outbound_timeout(self, timeout: Duration) -> TransportTimeout<Self>where
Self: Sized,
Adds a timeout to the connection and upgrade steps for all the outgoing sockets created
by the transport. Read more
sourcefn with_inbound_timeout(self, timeout: Duration) -> TransportTimeout<Self>where
Self: Sized,
fn with_inbound_timeout(self, timeout: Duration) -> TransportTimeout<Self>where
Self: Sized,
Adds a timeout to the connection and upgrade steps for all the incoming sockets created
by the transport. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for WsConfig<T>where
T: RefUnwindSafe,
impl<T> Send for WsConfig<T>where
T: Send,
impl<T> Sync for WsConfig<T>where
T: Sync,
impl<T> Unpin for WsConfig<T>where
T: Unpin,
impl<T> UnwindSafe for WsConfig<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more