From f8c0c0ed47a55019d57855e253d2fe5b6d9f38ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 14 Aug 2024 19:29:07 +0400 Subject: [PATCH] feat(blocking): teach single_sequence_step() to keep unmatched PDUs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The caller can gather the unmatching/unexpected PDUs as necessary. Signed-off-by: Marc-André Lureau --- crates/ironrdp-blocking/src/connector.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/ironrdp-blocking/src/connector.rs b/crates/ironrdp-blocking/src/connector.rs index 9f782335..e10611d8 100644 --- a/crates/ironrdp-blocking/src/connector.rs +++ b/crates/ironrdp-blocking/src/connector.rs @@ -1,5 +1,6 @@ use std::io::{Read, Write}; +use bytes::Bytes; use ironrdp_connector::credssp::{CredsspProcessGenerator, CredsspSequence, KerberosConfig}; use ironrdp_connector::sspi::credssp::ClientState; use ironrdp_connector::sspi::generator::GeneratorState; @@ -25,7 +26,7 @@ where info!("Begin connection procedure"); while !connector.should_perform_security_upgrade() { - single_sequence_step(framed, connector, &mut buf)?; + single_sequence_step(framed, connector, &mut buf, None)?; } Ok(ShouldUpgrade) @@ -78,7 +79,7 @@ where debug!("Remaining of connection sequence"); let result = loop { - single_sequence_step(framed, &mut connector, &mut buf)?; + single_sequence_step(framed, &mut connector, &mut buf, None)?; if let ClientConnectorState::Connected { result } = connector.state { break result; @@ -188,6 +189,7 @@ pub fn single_sequence_step( framed: &mut Framed, connector: &mut ClientConnector, buf: &mut WriteBuf, + unmatched: Option<&mut Vec>, ) -> ConnectorResult<()> where S: Read + Write, @@ -202,7 +204,7 @@ where ); let pdu = framed - .read_by_hint(next_pdu_hint, None) + .read_by_hint(next_pdu_hint, unmatched) .map_err(|e| ironrdp_connector::custom_err!("read frame by hint", e))?; trace!(length = pdu.len(), "PDU received");