aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol
diff options
context:
space:
mode:
author1zuna <1zuna@ccbluex.net>2023-11-30 01:25:58 +0100
committerGitHub <noreply@github.com>2023-11-29 18:25:58 -0600
commit8fb58b7754797b139ead1c68ece4ec1bf411455c (patch)
tree3b901a7df7e585ee4f1893a0b76f092a31aad1a2 /azalea-protocol
parent0f9492ff38faab191a181361b8748c45b459fb9d (diff)
downloadazalea-drasl-8fb58b7754797b139ead1c68ece4ec1bf411455c.tar.xz
fix trust_dns_resolver issue (#112)
fixes error: "Label contains invalid characters"
Diffstat (limited to 'azalea-protocol')
-rwxr-xr-xazalea-protocol/src/resolver.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/azalea-protocol/src/resolver.rs b/azalea-protocol/src/resolver.rs
index 79dd660f..f803df23 100755
--- a/azalea-protocol/src/resolver.rs
+++ b/azalea-protocol/src/resolver.rs
@@ -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(