Srv entry is no longer optional when using connect_with_srv
This commit is contained in:
parent
7b4a6e3ace
commit
5463a0aa99
3 changed files with 7 additions and 12 deletions
|
@ -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?,
|
||||
};
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue