summaryrefslogtreecommitdiffstats
path: root/src/connection.rs
diff options
context:
space:
mode:
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);