1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

fix trust_dns_resolver issue (#112)

fixes error: "Label contains invalid characters"
This commit is contained in:
1zuna 2023-11-30 01:25:58 +01:00 committed by GitHub
parent 0f9492ff38
commit 8fb58b7754
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ use std::net::{IpAddr, SocketAddr};
use thiserror::Error;
use trust_dns_resolver::{
config::{ResolverConfig, ResolverOpts},
TokioAsyncResolver,
TokioAsyncResolver, Name,
};
#[derive(Error, Debug)]
@ -45,7 +45,7 @@ pub async fn resolve_address(address: &ServerAddress) -> Result<SocketAddr, Reso
.next()
.ok_or(ResolverError::NoSrvRecord)?;
let redirect_address = ServerAddress {
host: redirect_srv.target().to_utf8(),
host: redirect_srv.target().to_ascii(),
port: redirect_srv.port(),
};
@ -58,13 +58,13 @@ pub async fn resolve_address(address: &ServerAddress) -> Result<SocketAddr, Reso
));
}
// debug!("redirecting to {:?}", redirect_address);
return resolve_address(&redirect_address).await;
}
// there's no redirect, try to resolve this as an ip address
let lookup_ip_result = resolver.lookup_ip(address.host.clone()).await;
let name = Name::from_ascii(&address.host)
.map_err(|_| ResolverError::NoIp)?;
let lookup_ip_result = resolver.lookup_ip(name).await;
let lookup_ip = lookup_ip_result.map_err(|_| ResolverError::NoIp)?;
Ok(SocketAddr::new(