Trait libp2p::core::InboundUpgrade
source · pub trait InboundUpgrade<C>: UpgradeInfo {
type Output;
type Error;
type Future: Future<Output = Result<Self::Output, Self::Error>>;
// Required method
fn upgrade_inbound(self, socket: C, info: Self::Info) -> Self::Future;
}
Expand description
Possible upgrade on an inbound connection or substream.
Required Associated Types§
Required Methods§
sourcefn upgrade_inbound(self, socket: C, info: Self::Info) -> Self::Future
fn upgrade_inbound(self, socket: C, info: Self::Info) -> Self::Future
After we have determined that the remote supports one of the protocols we support, this method is called to start the handshake.
The info
is the identifier of the protocol, as produced by protocol_info
.
Implementors§
source§impl<C> InboundUpgrade<C> for KademliaProtocolConfigwhere
C: AsyncRead + AsyncWrite + Unpin,
impl<C> InboundUpgrade<C> for KademliaProtocolConfigwhere C: AsyncRead + AsyncWrite + Unpin,
type Output = AndThen<With<ErrInto<Framed<C, UviBytes<Cursor<Vec<u8, Global>>>>, Error>, Cursor<Vec<u8, Global>>, KadResponseMsg, Ready<Result<Cursor<Vec<u8, Global>>, Error>>, fn(_: KadResponseMsg) -> Ready<Result<Cursor<Vec<u8, Global>>, Error>>>, Ready<Result<KadRequestMsg, Error>>, fn(_: BytesMut) -> Ready<Result<KadRequestMsg, Error>>>
type Future = Ready<Result<<KademliaProtocolConfig as InboundUpgrade<C>>::Output, Error>>
type Error = Error
source§impl<C> InboundUpgrade<C> for MplexConfigwhere
C: AsyncRead + AsyncWrite + Unpin,
impl<C> InboundUpgrade<C> for MplexConfigwhere C: AsyncRead + AsyncWrite + Unpin,
source§impl<C> InboundUpgrade<C> for YamuxConfigwhere
C: AsyncRead + AsyncWrite + Send + Unpin + 'static,
impl<C> InboundUpgrade<C> for YamuxConfigwhere C: AsyncRead + AsyncWrite + Send + Unpin + 'static,
type Output = Yamux<Incoming<C>>
type Error = Error
type Future = Ready<Result<<YamuxConfig as InboundUpgrade<C>>::Output, <YamuxConfig as InboundUpgrade<C>>::Error>>
source§impl<C> InboundUpgrade<C> for YamuxLocalConfigwhere
C: AsyncRead + AsyncWrite + Unpin + 'static,
impl<C> InboundUpgrade<C> for YamuxLocalConfigwhere C: AsyncRead + AsyncWrite + Unpin + 'static,
type Output = Yamux<LocalIncoming<C>>
type Error = Error
type Future = Ready<Result<<YamuxLocalConfig as InboundUpgrade<C>>::Output, <YamuxLocalConfig as InboundUpgrade<C>>::Error>>
source§impl<C> InboundUpgrade<C> for DeniedUpgrade
impl<C> InboundUpgrade<C> for DeniedUpgrade
type Output = Void
type Error = Void
type Future = Pending<Result<<DeniedUpgrade as InboundUpgrade<C>>::Output, <DeniedUpgrade as InboundUpgrade<C>>::Error>>
source§impl<C, A, B, TA, TB, EA, EB> InboundUpgrade<C> for EitherUpgrade<A, B>where
A: InboundUpgrade<C, Output = TA, Error = EA>,
B: InboundUpgrade<C, Output = TB, Error = EB>,
impl<C, A, B, TA, TB, EA, EB> InboundUpgrade<C> for EitherUpgrade<A, B>where A: InboundUpgrade<C, Output = TA, Error = EA>, B: InboundUpgrade<C, Output = TB, Error = EB>,
type Output = EitherOutput<TA, TB>
type Error = EitherError<EA, EB>
type Future = EitherFuture2<<A as InboundUpgrade<C>>::Future, <B as InboundUpgrade<C>>::Future>
source§impl<C, A, B, TA, TB, EA, EB> InboundUpgrade<C> for SelectUpgrade<A, B>where
A: InboundUpgrade<C, Output = TA, Error = EA>,
B: InboundUpgrade<C, Output = TB, Error = EB>,
impl<C, A, B, TA, TB, EA, EB> InboundUpgrade<C> for SelectUpgrade<A, B>where A: InboundUpgrade<C, Output = TA, Error = EA>, B: InboundUpgrade<C, Output = TB, Error = EB>,
type Output = EitherOutput<TA, TB>
type Error = EitherError<EA, EB>
type Future = EitherFuture2<<A as InboundUpgrade<C>>::Future, <B as InboundUpgrade<C>>::Future>
source§impl<C, F, O, A, E> InboundUpgrade<C> for SimpleProtocol<F>where
C: AsyncRead + AsyncWrite,
F: Fn(C) -> O,
O: Future<Output = Result<A, E>>,
impl<C, F, O, A, E> InboundUpgrade<C> for SimpleProtocol<F>where C: AsyncRead + AsyncWrite, F: Fn(C) -> O, O: Future<Output = Result<A, E>>,
source§impl<C, P> InboundUpgrade<C> for PendingUpgrade<P>where
P: ProtocolName + Clone,
impl<C, P> InboundUpgrade<C> for PendingUpgrade<P>where P: ProtocolName + Clone,
type Output = Void
type Error = Void
type Future = Pending<Result<<PendingUpgrade<P> as InboundUpgrade<C>>::Output, <PendingUpgrade<P> as InboundUpgrade<C>>::Error>>
source§impl<C, P> InboundUpgrade<C> for ReadyUpgrade<P>where
P: ProtocolName + Clone,
impl<C, P> InboundUpgrade<C> for ReadyUpgrade<P>where P: ProtocolName + Clone,
type Output = C
type Error = Void
type Future = Ready<Result<<ReadyUpgrade<P> as InboundUpgrade<C>>::Output, <ReadyUpgrade<P> as InboundUpgrade<C>>::Error>>
source§impl<C, P, F, Fut, Err, Out> InboundUpgrade<C> for FromFnUpgrade<P, F>where
P: ProtocolName + Clone,
F: FnOnce(C, Endpoint) -> Fut,
Fut: Future<Output = Result<Out, Err>>,
impl<C, P, F, Fut, Err, Out> InboundUpgrade<C> for FromFnUpgrade<P, F>where P: ProtocolName + Clone, F: FnOnce(C, Endpoint) -> Fut, Fut: Future<Output = Result<Out, Err>>,
source§impl<C, T> InboundUpgrade<C> for OptionalUpgrade<T>where
T: InboundUpgrade<C>,
impl<C, T> InboundUpgrade<C> for OptionalUpgrade<T>where T: InboundUpgrade<C>,
type Output = <T as InboundUpgrade<C>>::Output
type Error = <T as InboundUpgrade<C>>::Error
type Future = <T as InboundUpgrade<C>>::Future
source§impl<C, U, F> InboundUpgrade<C> for MapOutboundUpgrade<U, F>where
U: InboundUpgrade<C>,
impl<C, U, F> InboundUpgrade<C> for MapOutboundUpgrade<U, F>where U: InboundUpgrade<C>,
type Output = <U as InboundUpgrade<C>>::Output
type Error = <U as InboundUpgrade<C>>::Error
type Future = <U as InboundUpgrade<C>>::Future
source§impl<C, U, F> InboundUpgrade<C> for MapOutboundUpgradeErr<U, F>where
U: InboundUpgrade<C>,
impl<C, U, F> InboundUpgrade<C> for MapOutboundUpgradeErr<U, F>where U: InboundUpgrade<C>,
type Output = <U as InboundUpgrade<C>>::Output
type Error = <U as InboundUpgrade<C>>::Error
type Future = <U as InboundUpgrade<C>>::Future
source§impl<C, U, F, T> InboundUpgrade<C> for MapInboundUpgrade<U, F>where
U: InboundUpgrade<C>,
F: FnOnce(<U as InboundUpgrade<C>>::Output) -> T,
impl<C, U, F, T> InboundUpgrade<C> for MapInboundUpgrade<U, F>where U: InboundUpgrade<C>, F: FnOnce(<U as InboundUpgrade<C>>::Output) -> T,
type Output = T
type Error = <U as InboundUpgrade<C>>::Error
type Future = MapFuture<<U as InboundUpgrade<C>>::Future, F>
source§impl<C, U, F, T> InboundUpgrade<C> for MapInboundUpgradeErr<U, F>where
U: InboundUpgrade<C>,
F: FnOnce(<U as InboundUpgrade<C>>::Error) -> T,
impl<C, U, F, T> InboundUpgrade<C> for MapInboundUpgradeErr<U, F>where U: InboundUpgrade<C>, F: FnOnce(<U as InboundUpgrade<C>>::Error) -> T,
type Output = <U as InboundUpgrade<C>>::Output
type Error = T
type Future = MapErrFuture<<U as InboundUpgrade<C>>::Future, F>
source§impl<T> InboundUpgrade<Negotiated<SubstreamBox>> for SendWrapper<T>where
T: InboundUpgradeSend,
impl<T> InboundUpgrade<Negotiated<SubstreamBox>> for SendWrapper<T>where T: InboundUpgradeSend,
type Output = <T as InboundUpgradeSend>::Output
type Error = <T as InboundUpgradeSend>::Error
type Future = <T as InboundUpgradeSend>::Future
source§impl<T, C> InboundUpgrade<T> for NoiseConfig<IK, C, ()>where
NoiseConfig<IK, C, ()>: UpgradeInfo,
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
C: Protocol<C> + AsRef<[u8]> + Zeroize + Clone + Send + 'static,
impl<T, C> InboundUpgrade<T> for NoiseConfig<IK, C, ()>where NoiseConfig<IK, C, ()>: UpgradeInfo, T: AsyncRead + AsyncWrite + Unpin + Send + 'static, C: Protocol<C> + AsRef<[u8]> + Zeroize + Clone + Send + 'static,
Implements the responder part of the IK
handshake pattern.
IK
is a single round-trip (2 messages) handshake.
In the IK
handshake, the initiator is expected to know the responder’s identity already, which
is why the responder does not send it in the second message.
initiator -{id}-> responder
initiator <-{id}- responder
type Output = (RemoteIdentity<C>, NoiseOutput<T>)
type Error = NoiseError
type Future = Pin<Box<dyn Future<Output = Result<(RemoteIdentity<C>, NoiseOutput<T>), NoiseError>> + Send, Global>>
source§impl<T, C> InboundUpgrade<T> for NoiseConfig<IX, C, ()>where
NoiseConfig<IX, C, ()>: UpgradeInfo,
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
C: Protocol<C> + AsRef<[u8]> + Zeroize + Clone + Send + 'static,
impl<T, C> InboundUpgrade<T> for NoiseConfig<IX, C, ()>where NoiseConfig<IX, C, ()>: UpgradeInfo, T: AsyncRead + AsyncWrite + Unpin + Send + 'static, C: Protocol<C> + AsRef<[u8]> + Zeroize + Clone + Send + 'static,
Implements the responder part of the IX
noise handshake pattern.
IX
is a single round-trip (2 messages) handshake in which each party sends their identity over to the other party.
initiator -{id}-> responder
initiator <-{id}- responder
type Output = (RemoteIdentity<C>, NoiseOutput<T>)
type Error = NoiseError
type Future = Pin<Box<dyn Future<Output = Result<(RemoteIdentity<C>, NoiseOutput<T>), NoiseError>> + Send, Global>>
source§impl<T, C> InboundUpgrade<T> for NoiseConfig<XX, C, ()>where
NoiseConfig<XX, C, ()>: UpgradeInfo,
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
C: Protocol<C> + AsRef<[u8]> + Zeroize + Clone + Send + 'static,
impl<T, C> InboundUpgrade<T> for NoiseConfig<XX, C, ()>where NoiseConfig<XX, C, ()>: UpgradeInfo, T: AsyncRead + AsyncWrite + Unpin + Send + 'static, C: Protocol<C> + AsRef<[u8]> + Zeroize + Clone + Send + 'static,
Implements the responder part of the XX
noise handshake pattern.
XX
is a 1.5 round-trip (3 messages) handshake.
The first message in a noise handshake is unencrypted. In the XX
handshake pattern, that message
is empty and thus does not leak any information. The identities are then exchanged in the second
and third message.
initiator --{}--> responder
initiator <-{id}- responder
initiator -{id}-> responder