summaryrefslogtreecommitdiffstats
path: root/src/connection.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2023-10-28 21:06:42 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2023-10-28 21:06:42 +0100
commita1f3cf450bfd470d1a655c53503acbb4d2b8f851 (patch)
tree6c7f48cf666ab14493d527f7bb503c01b3ecce16 /src/connection.rs
parentc16f299364317904a98e162bba8acdeb587c8e63 (diff)
downloadluz-a1f3cf450bfd470d1a655c53503acbb4d2b8f851.tar.gz
luz-a1f3cf450bfd470d1a655c53503acbb4d2b8f851.tar.bz2
luz-a1f3cf450bfd470d1a655c53503acbb4d2b8f851.zip
implement stream start
Diffstat (limited to '')
-rw-r--r--src/connection.rs9
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);