change ensure_tls to no longer start stream

This commit is contained in:
cel 🌸 2024-11-28 19:06:20 +00:00
parent 668270429f
commit 2dcbc9e1f4
2 changed files with 5 additions and 3 deletions

View File

@ -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),

View File

@ -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);