Srv entry is no longer optional when using connect_with_srv

This commit is contained in:
Paul Fariello 2020-12-06 15:31:27 +01:00
parent 7b4a6e3ace
commit 5463a0aa99
3 changed files with 7 additions and 12 deletions

View file

@ -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?,
};

View file

@ -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 =

View file

@ -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_records = resolver.srv_lookup(srv_domain).await.ok();
match srv_records {
Some(lookup) => {