mirror of
https://github.com/netbirdio/IronRDP.git
synced 2026-05-22 18:43:12 -07:00
feat(async): teach single_sequence_step() to keep unmatched PDUs
The caller can gather the unmatching/unexpected PDUs as necessary. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
committed by
Benoît Cortier
parent
6f779406e6
commit
e54fa5f4c8
@@ -41,7 +41,7 @@ where
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
single_sequence_step(&mut framed, acceptor, &mut buf).await?;
|
||||
single_sequence_step(&mut framed, acceptor, &mut buf, None).await?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ where
|
||||
return Ok((framed, result));
|
||||
}
|
||||
|
||||
single_sequence_step(&mut framed, acceptor, &mut buf).await?;
|
||||
single_sequence_step(&mut framed, acceptor, &mut buf, None).await?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ where
|
||||
info!("Begin connection procedure");
|
||||
|
||||
while !connector.should_perform_security_upgrade() {
|
||||
single_sequence_step(framed, connector, &mut buf).await?;
|
||||
single_sequence_step(framed, connector, &mut buf, None).await?;
|
||||
}
|
||||
|
||||
Ok(ShouldUpgrade)
|
||||
@@ -73,7 +73,7 @@ where
|
||||
}
|
||||
|
||||
let result = loop {
|
||||
single_sequence_step(framed, &mut connector, &mut buf).await?;
|
||||
single_sequence_step(framed, &mut connector, &mut buf, None).await?;
|
||||
|
||||
if let ClientConnectorState::Connected { result } = connector.state {
|
||||
break result;
|
||||
|
||||
@@ -230,12 +230,13 @@ pub async fn single_sequence_step<S>(
|
||||
framed: &mut Framed<S>,
|
||||
sequence: &mut dyn Sequence,
|
||||
buf: &mut WriteBuf,
|
||||
unmatched: Option<&mut Vec<Bytes>>,
|
||||
) -> ConnectorResult<()>
|
||||
where
|
||||
S: FramedWrite + FramedRead,
|
||||
{
|
||||
buf.clear();
|
||||
let written = single_sequence_step_read(framed, sequence, buf).await?;
|
||||
let written = single_sequence_step_read(framed, sequence, buf, unmatched).await?;
|
||||
single_sequence_step_write(framed, buf, written).await
|
||||
}
|
||||
|
||||
@@ -243,6 +244,7 @@ pub async fn single_sequence_step_read<S>(
|
||||
framed: &mut Framed<S>,
|
||||
sequence: &mut dyn Sequence,
|
||||
buf: &mut WriteBuf,
|
||||
unmatched: Option<&mut Vec<Bytes>>,
|
||||
) -> ConnectorResult<Written>
|
||||
where
|
||||
S: FramedRead,
|
||||
@@ -257,7 +259,7 @@ where
|
||||
);
|
||||
|
||||
let pdu = framed
|
||||
.read_by_hint(next_pdu_hint, None)
|
||||
.read_by_hint(next_pdu_hint, unmatched)
|
||||
.await
|
||||
.map_err(|e| ironrdp_connector::custom_err!("read frame by hint", e))?;
|
||||
|
||||
|
||||
@@ -294,9 +294,10 @@ async fn active_session(
|
||||
debug!("Received Server Deactivate All PDU, executing Deactivation-Reactivation Sequence");
|
||||
let mut buf = WriteBuf::new();
|
||||
'activation_seq: loop {
|
||||
let written = single_sequence_step_read(&mut framed, &mut *connection_activation, &mut buf)
|
||||
.await
|
||||
.map_err(|e| session::custom_err!("read deactivation-reactivation sequence step", e))?;
|
||||
let written =
|
||||
single_sequence_step_read(&mut framed, &mut *connection_activation, &mut buf, None)
|
||||
.await
|
||||
.map_err(|e| session::custom_err!("read deactivation-reactivation sequence step", e))?;
|
||||
|
||||
if written.size().is_some() {
|
||||
framed.write_all(buf.filled()).await.map_err(|e| {
|
||||
|
||||
@@ -616,7 +616,7 @@ impl Session {
|
||||
let mut buf = WriteBuf::new();
|
||||
'activation_seq: loop {
|
||||
let written =
|
||||
single_sequence_step_read(&mut framed, &mut *box_connection_activation, &mut buf)
|
||||
single_sequence_step_read(&mut framed, &mut *box_connection_activation, &mut buf, None)
|
||||
.await?;
|
||||
|
||||
if written.size().is_some() {
|
||||
|
||||
Reference in New Issue
Block a user