fix(cbs): added missing parts of the handshake

This commit is contained in:
antifallobst 2024-05-21 04:59:23 +02:00
parent f6a1b5200a
commit fc8efe5060
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
1 changed files with 18 additions and 7 deletions

View File

@ -56,6 +56,8 @@ impl UnstableConnection {
let packet = Packet::recv(&mut sock_rx, &cipher, &nonce).await?; let packet = Packet::recv(&mut sock_rx, &cipher, &nonce).await?;
match packet { match packet {
Packet::Request { id, body } => { Packet::Request { id, body } => {
match body {
Request::HandshakeUpgradeConnection => {
Packet::response(id_pool.acquire(), id, Response::Success) Packet::response(id_pool.acquire(), id, Response::Success)
.send(&mut sock_tx, &cipher, &nonce) .send(&mut sock_tx, &cipher, &nonce)
.await?; .await?;
@ -65,6 +67,11 @@ impl UnstableConnection {
id = self.id id = self.id
); );
} }
req => return Err(anyhow!(
"expected cbs to send: Request::HandshakeUpgradeConnection, but got: Request::{req}"
))
}
}
body => { body => {
return Err(anyhow!( return Err(anyhow!(
"expected cbs to send: Request::HandshakeUpgradeConnection, but got: {body}" "expected cbs to send: Request::HandshakeUpgradeConnection, but got: {body}"
@ -72,6 +79,10 @@ impl UnstableConnection {
} }
} }
Packet::request(id_pool.acquire(), Request::HandshakeSuccess)
.send(&mut sock_tx, &cipher, &nonce)
.await?;
// Poll packets from socket // Poll packets from socket
{ {
let cipher = cipher.clone(); let cipher = cipher.clone();