Implement CBS API handling on the trinitrix core side. #23

Merged
antifallobst merged 8 commits from cbs-core into main 2024-05-21 21:09:48 +00:00
1 changed files with 18 additions and 7 deletions
Showing only changes of commit fc8efe5060 - Show all commits

View File

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