From 99f3811c71370cbb18b0959fe05845ba4f14a97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 18 Jun 2023 16:46:49 +0200 Subject: [PATCH] tokio-xmpp: Add debug for chosen DNS method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- tokio-xmpp/src/happy_eyeballs.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tokio-xmpp/src/happy_eyeballs.rs b/tokio-xmpp/src/happy_eyeballs.rs index 0c1300a..123a5a2 100644 --- a/tokio-xmpp/src/happy_eyeballs.rs +++ b/tokio-xmpp/src/happy_eyeballs.rs @@ -1,5 +1,6 @@ use crate::{ConnecterError, Error}; use idna; +use log::debug; use std::net::SocketAddr; use tokio::net::TcpStream; use trust_dns_resolver::{IntoName, TokioAsyncResolver}; @@ -34,6 +35,7 @@ pub async fn connect_with_srv( let ascii_domain = idna::domain_to_ascii(&domain).map_err(|_| Error::Idna)?; if let Ok(ip) = ascii_domain.parse() { + debug!("Attempting connection to {ip}:{fallback_port}"); return Ok(TcpStream::connect(&SocketAddr::new(ip, fallback_port)).await?); } @@ -42,12 +44,13 @@ pub async fn connect_with_srv( let srv_domain = format!("{}.{}.", srv, ascii_domain) .into_name() .map_err(ConnecterError::Dns)?; - let srv_records = resolver.srv_lookup(srv_domain).await.ok(); + let srv_records = resolver.srv_lookup(srv_domain.clone()).await.ok(); match srv_records { Some(lookup) => { // TODO: sort lookup records by priority/weight for srv in lookup.iter() { + debug!("Attempting connection to {srv_domain} {srv}"); match connect_to_host(&srv.target().to_ascii(), srv.port()).await { Ok(stream) => return Ok(stream), Err(_) => {} @@ -57,6 +60,7 @@ pub async fn connect_with_srv( } None => { // SRV lookup error, retry with hostname + debug!("Attempting connection to {domain}:{fallback_port}"); connect_to_host(domain, fallback_port).await } }