aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2024-11-28 19:06:20 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2024-11-28 19:06:20 +0000
commit2dcbc9e1f4339993dd47b2659770a9cf4855b02d (patch)
treefd26a3d8b24faa2146c3634ad160c062fcd05b12
parent668270429f9b59f71c21daa7f92a28d422503bb7 (diff)
downloadluz-2dcbc9e1f4339993dd47b2659770a9cf4855b02d.tar.gz
luz-2dcbc9e1f4339993dd47b2659770a9cf4855b02d.tar.bz2
luz-2dcbc9e1f4339993dd47b2659770a9cf4855b02d.zip
change ensure_tls to no longer start stream
-rw-r--r--src/connection.rs1
-rw-r--r--src/jabber.rs7
2 files changed, 5 insertions, 3 deletions
diff --git a/src/connection.rs b/src/connection.rs
index 2b70747..65e9383 100644
--- a/src/connection.rs
+++ b/src/connection.rs
@@ -23,6 +23,7 @@ pub enum Connection {
impl Connection {
#[instrument]
+ /// stream not started
pub async fn ensure_tls(self) -> Result<Jabber<Tls>> {
match self {
Connection::Encrypted(j) => Ok(j),
diff --git a/src/jabber.rs b/src/jabber.rs
index 87a2b44..a56c65c 100644
--- a/src/jabber.rs
+++ b/src/jabber.rs
@@ -6,7 +6,7 @@ use peanuts::{Reader, Writer};
use rsasl::prelude::SASLConfig;
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, BufReader, ReadHalf, WriteHalf};
use tokio_native_tls::native_tls::TlsConnector;
-use tracing::{debug, info, trace};
+use tracing::{debug, info, instrument, trace};
use trust_dns_resolver::proto::rr::domain::IntoLabel;
use crate::connection::{Tls, Unencrypted};
@@ -54,9 +54,11 @@ where
impl<S> Jabber<S>
where
S: AsyncRead + AsyncWrite + Unpin + Send,
+ Jabber<S>: std::fmt::Debug,
{
// pub async fn negotiate(self) -> Result<Jabber<S>> {}
+ #[instrument]
pub async fn start_stream(&mut self) -> Result<()> {
// client to server
@@ -109,14 +111,13 @@ impl Jabber<Unencrypted> {
.await
{
let (read, write) = tokio::io::split(tlsstream);
- let mut client = Jabber::new(
+ let client = Jabber::new(
read,
write,
self.jid.to_owned(),
self.auth.to_owned(),
self.server.to_owned(),
);
- client.start_stream().await?;
return Ok(client);
} else {
return Err(Error::Connection);