Skip to content

Commit

Permalink
disable srv lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Mar 27, 2024
1 parent 2aff7f8 commit 9db03c4
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions azalea-protocol/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,7 @@ pub async fn resolve_address(address: &ServerAddress) -> Result<SocketAddr, Reso
// trust_dns_resolver has an issue on Windows where it's really slow using the
// default resolver
let resolver = TokioAsyncResolver::tokio(ResolverConfig::cloudflare(), ResolverOpts::default());

// first, we do a srv lookup for _minecraft._tcp.<host>
let srv_redirect_result = resolver
.srv_lookup(format!("_minecraft._tcp.{}", address.host).as_str())
.await;

// if it resolves that means it's a redirect so we call resolve_address again
// with the new host
if let Ok(redirect_result) = srv_redirect_result {
let redirect_srv = redirect_result
.iter()
.next()
.ok_or(ResolverError::NoSrvRecord)?;
let redirect_address = ServerAddress {
host: redirect_srv.target().to_ascii(),
port: redirect_srv.port(),
};

if redirect_address.host == address.host {
let lookup_ip_result = resolver.lookup_ip(redirect_address.host).await;
let lookup_ip = lookup_ip_result.map_err(|_| ResolverError::NoIp)?;
return Ok(SocketAddr::new(
lookup_ip.iter().next().unwrap(),
redirect_address.port,
));
}

return resolve_address(&redirect_address).await;
}


// there's no redirect, try to resolve this as an ip address
let name = Name::from_ascii(&address.host).map_err(|_| ResolverError::NoIp)?;
let lookup_ip_result = resolver.lookup_ip(name).await;
Expand Down

0 comments on commit 9db03c4

Please sign in to comment.