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 { impl Connection {
#[instrument] #[instrument]
/// stream not started
pub async fn ensure_tls(self) -> Result<Jabber<Tls>> { pub async fn ensure_tls(self) -> Result<Jabber<Tls>> {
match self { match self {
Connection::Encrypted(j) => Ok(j), Connection::Encrypted(j) => Ok(j),

View File

@ -6,7 +6,7 @@ use peanuts::{Reader, Writer};
use rsasl::prelude::SASLConfig; use rsasl::prelude::SASLConfig;
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, BufReader, ReadHalf, WriteHalf}; use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, BufReader, ReadHalf, WriteHalf};
use tokio_native_tls::native_tls::TlsConnector; 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 trust_dns_resolver::proto::rr::domain::IntoLabel;
use crate::connection::{Tls, Unencrypted}; use crate::connection::{Tls, Unencrypted};
@ -54,9 +54,11 @@ where
impl<S> Jabber<S> impl<S> Jabber<S>
where where
S: AsyncRead + AsyncWrite + Unpin + Send, S: AsyncRead + AsyncWrite + Unpin + Send,
Jabber<S>: std::fmt::Debug,
{ {
// pub async fn negotiate(self) -> Result<Jabber<S>> {} // pub async fn negotiate(self) -> Result<Jabber<S>> {}
#[instrument]
pub async fn start_stream(&mut self) -> Result<()> { pub async fn start_stream(&mut self) -> Result<()> {
// client to server // client to server
@ -109,14 +111,13 @@ impl Jabber<Unencrypted> {
.await .await
{ {
let (read, write) = tokio::io::split(tlsstream); let (read, write) = tokio::io::split(tlsstream);
let mut client = Jabber::new( let client = Jabber::new(
read, read,
write, write,
self.jid.to_owned(), self.jid.to_owned(),
self.auth.to_owned(), self.auth.to_owned(),
self.server.to_owned(), self.server.to_owned(),
); );
client.start_stream().await?;
return Ok(client); return Ok(client);
} else { } else {
return Err(Error::Connection); return Err(Error::Connection);