//! `starttls::ServerConfig` provides a `ServerConnector` for starttls connections use tokio::net::TcpStream; use crate::{ connect::{DnsConfig, ServerConnector}, proto::XmppStream, Client, Component, Error, }; /// Component that connects over TCP pub type TcpComponent = Component; /// Client that connects over TCP pub type TcpClient = Client; /// Connect via insecure plaintext TCP to an XMPP server /// This should only be used over localhost or otherwise when you know what you are doing /// Probably mostly useful for Components #[derive(Debug, Clone)] pub struct TcpServerConnector(pub DnsConfig); impl From for TcpServerConnector { fn from(dns_config: DnsConfig) -> TcpServerConnector { Self(dns_config) } } impl ServerConnector for TcpServerConnector { type Stream = TcpStream; async fn connect( &self, jid: &xmpp_parsers::jid::Jid, ns: &str, ) -> Result, Error> { let stream = self.0.resolve().await?; Ok(XmppStream::start(stream, jid.clone(), ns.to_owned()).await?) } }