From a1f3cf450bfd470d1a655c53503acbb4d2b8f851 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Sat, 28 Oct 2023 21:06:42 +0100 Subject: implement stream start --- src/connection.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/connection.rs') diff --git a/src/connection.rs b/src/connection.rs index ccc2ae7..b42711e 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -15,16 +15,21 @@ use crate::Result; pub type Tls = TlsStream; pub type Unencrypted = TcpStream; +#[derive(Debug)] pub enum Connection { Encrypted(Jabber), Unencrypted(Jabber), } impl Connection { + #[instrument] pub async fn ensure_tls(self) -> Result> { match self { Connection::Encrypted(j) => Ok(j), - Connection::Unencrypted(j) => Ok(j.starttls().await?), + Connection::Unencrypted(mut j) => { + info!("upgrading connection to tls"); + Ok(j.starttls().await?) + } } } @@ -36,7 +41,7 @@ impl Connection { // } #[instrument] - async fn connect(server: &str) -> Result { + pub async fn connect(server: &str) -> Result { info!("connecting to {}", server); let sockets = Self::get_sockets(&server).await; debug!("discovered sockets: {:?}", sockets); -- cgit