From 5463a0aa99ee3088d6e235e03d9a2a6f5206082d Mon Sep 17 00:00:00 2001 From: Paul Fariello Date: Sun, 6 Dec 2020 15:31:27 +0100 Subject: [PATCH] Srv entry is no longer optional when using connect_with_srv --- 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(-) diff --git a/tokio-xmpp/src/client/async_client.rs b/tokio-xmpp/src/client/async_client.rs index 9f75c96e..79a7aa07 100644 --- a/tokio-xmpp/src/client/async_client.rs +++ b/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?, }; diff --git a/tokio-xmpp/src/client/simple_client.rs b/tokio-xmpp/src/client/simple_client.rs index 4f90ca27..a2d666a8 100644 --- a/tokio-xmpp/src/client/simple_client.rs +++ b/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 = diff --git a/tokio-xmpp/src/happy_eyeballs.rs b/tokio-xmpp/src/happy_eyeballs.rs index 5ad09729..0c1300aa 100644 --- a/tokio-xmpp/src/happy_eyeballs.rs +++ b/tokio-xmpp/src/happy_eyeballs.rs @@ -28,7 +28,7 @@ pub async fn connect_to_host(domain: &str, port: u16) -> Result, + srv: &str, fallback_port: u16, ) -> Result { 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) => {