pub struct PendingSession<S> { /* private fields */ }Expand description
A stream whose first Noise message has been read but not yet processed.
This exists so that a responder can act on the initiator’s cleartext payload before deriving
any keys. Everything up to PendingSession::into_session is reading and parsing, so a peer that
is going to be turned away - one that is not an authorized validator, say - costs no scalar
multiplications. Under a distributed flood of connection attempts, that is the difference between
paying for five of them per rejected peer and paying for none.
Implementations§
Source§impl<S: AsyncRead + AsyncWrite + Unpin> PendingSession<S>
impl<S: AsyncRead + AsyncWrite + Unpin> PendingSession<S>
Sourcepub async fn accept(stream: S) -> Result<Self>
pub async fn accept(stream: S) -> Result<Self>
Reads the pattern’s first message from the given stream.
The caller is responsible for the NOISE_MAGIC prefix, which must already have been
consumed with detect_handshake_protocol.
Sourcepub fn first_payload(&self) -> Result<&[u8]>
pub fn first_payload(&self) -> Result<&[u8]>
Returns the payload the initiator sent alongside its ephemeral key.
It is neither encrypted nor authenticated, so it is a claim and not a fact: anything acted on here has to be re-checked against the authenticated copy later in the handshake.
Sourcepub fn into_session(self) -> Result<NoiseSession<S>>
pub fn into_session(self) -> Result<NoiseSession<S>>
Derives the responder’s keys and processes the first message.
Auto Trait Implementations§
impl<S> Freeze for PendingSession<S>where
S: Freeze,
impl<S> RefUnwindSafe for PendingSession<S>where
S: RefUnwindSafe,
impl<S> Send for PendingSession<S>where
S: Send,
impl<S> Sync for PendingSession<S>where
S: Sync,
impl<S> Unpin for PendingSession<S>where
S: Unpin,
impl<S> UnsafeUnpin for PendingSession<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for PendingSession<S>where
S: UnwindSafe,
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> 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