This commit is contained in:
nora 2022-02-13 20:51:24 +01:00
parent 2903ba108e
commit 2455e95d45
7 changed files with 1493 additions and 1175 deletions

View file

@ -1,5 +1,5 @@
use crate::classes::FieldValue;
use crate::error::{ProtocolError, Result};
use crate::error::{ConException, ProtocolError, Result};
use crate::frame::{Frame, FrameType};
use crate::{classes, frame};
use anyhow::Context;
@ -54,7 +54,7 @@ impl Connection {
.local_addr()
.context("failed to get local_addr")?,
),
mechanisms: "none".to_string().into(),
mechanisms: "PLAIN".to_string().into(),
locales: "en_US".to_string().into(),
});
@ -72,6 +72,17 @@ impl Connection {
)
.await?;
let start_ok_frame = frame::read_frame(&mut self.stream, self.max_frame_size).await?;
debug!(?start_ok_frame, "Received Start-Ok frame");
if start_ok_frame.kind != FrameType::Method {
return Err(ProtocolError::ConException(ConException::Todo).into());
}
let class = classes::parse_method(&start_ok_frame.payload)?;
debug!(?class, "extracted method");
Ok(())
}
@ -120,6 +131,8 @@ fn server_properties(host: SocketAddr) -> classes::Table {
FieldValue::LongString(host_str.into())
};
// todo: fix
//HashMap::from([
// ("host".to_string(), host_value),
// ("product".to_string(), ss("no name yet")),