diff options
author | cel 🌸 <cel@blos.sm> | 2023-10-28 21:06:42 +0100 |
---|---|---|
committer | cel 🌸 <cel@blos.sm> | 2023-10-28 21:06:42 +0100 |
commit | a1f3cf450bfd470d1a655c53503acbb4d2b8f851 (patch) | |
tree | 6c7f48cf666ab14493d527f7bb503c01b3ecce16 /src/connection.rs | |
parent | c16f299364317904a98e162bba8acdeb587c8e63 (diff) | |
download | luz-a1f3cf450bfd470d1a655c53503acbb4d2b8f851.tar.gz luz-a1f3cf450bfd470d1a655c53503acbb4d2b8f851.tar.bz2 luz-a1f3cf450bfd470d1a655c53503acbb4d2b8f851.zip |
implement stream start
Diffstat (limited to '')
-rw-r--r-- | src/connection.rs | 9 |
1 files changed, 7 insertions, 2 deletions
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<TcpStream>; pub type Unencrypted = TcpStream; +#[derive(Debug)] pub enum Connection { Encrypted(Jabber<Tls>), Unencrypted(Jabber<Unencrypted>), } impl Connection { + #[instrument] pub async fn ensure_tls(self) -> Result<Jabber<Tls>> { 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<Self> { + pub async fn connect(server: &str) -> Result<Self> { info!("connecting to {}", server); let sockets = Self::get_sockets(&server).await; debug!("discovered sockets: {:?}", sockets); |