Srv entry is no longer optional when using connect_with_srv

Paul Fariello created

Change summary

tokio-xmpp/src/client/async_client.rs  |  2 +-
tokio-xmpp/src/client/simple_client.rs |  2 +-
tokio-xmpp/src/happy_eyeballs.rs       | 15 +++++----------
3 files changed, 7 insertions(+), 12 deletions(-)

Detailed changes

tokio-xmpp/src/client/async_client.rs 🔗

@@ -109,7 +109,7 @@ impl Client {
         // TCP connection
         let tcp_stream = match server {
             ServerConfig::UseSrv => {
-                connect_with_srv(&jid.clone().domain(), Some("_xmpp-client._tcp"), 5222).await?
+                connect_with_srv(&jid.clone().domain(), "_xmpp-client._tcp", 5222).await?
             }
             ServerConfig::Manual { host, port } => connect_to_host(host.as_str(), port).await?,
         };

tokio-xmpp/src/client/simple_client.rs 🔗

@@ -47,7 +47,7 @@ impl Client {
         let domain = idna::domain_to_ascii(&jid.clone().domain()).map_err(|_| Error::Idna)?;
 
         // TCP connection
-        let tcp_stream = connect_with_srv(&domain, Some("_xmpp-client._tcp"), 5222).await?;
+        let tcp_stream = connect_with_srv(&domain, "_xmpp-client._tcp", 5222).await?;
 
         // Unencryped XMPPStream
         let xmpp_stream =

tokio-xmpp/src/happy_eyeballs.rs 🔗

@@ -28,7 +28,7 @@ pub async fn connect_to_host(domain: &str, port: u16) -> Result<TcpStream, Error
 
 pub async fn connect_with_srv(
     domain: &str,
-    srv: Option<&str>,
+    srv: &str,
     fallback_port: u16,
 ) -> Result<TcpStream, Error> {
     let ascii_domain = idna::domain_to_ascii(&domain).map_err(|_| Error::Idna)?;
@@ -39,15 +39,10 @@ pub async fn connect_with_srv(
 
     let resolver = TokioAsyncResolver::tokio_from_system_conf().map_err(ConnecterError::Resolve)?;
 
-    let srv_records = match srv {
-        Some(srv) => {
-            let srv_domain = format!("{}.{}.", srv, ascii_domain)
-                .into_name()
-                .map_err(ConnecterError::Dns)?;
-            resolver.srv_lookup(srv_domain).await.ok()
-        }
-        None => None,
-    };
+    let srv_domain = format!("{}.{}.", srv, ascii_domain)
+        .into_name()
+        .map_err(ConnecterError::Dns)?;
+    let srv_records = resolver.srv_lookup(srv_domain).await.ok();
 
     match srv_records {
         Some(lookup) => {