Skip to content

Commit 159b58c

Browse files
committed
fix
1 parent e94a049 commit 159b58c

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

libs/llrt_dns_cache/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{
44
future::Future,
55
io,
6-
net::{Ipv4Addr, Ipv6Addr, SocketAddr},
6+
net::{SocketAddr, SocketAddrV4, SocketAddrV6},
77
pin::Pin,
88
result::Result as StdResult,
99
str::FromStr,
@@ -176,13 +176,13 @@ pub async fn lookup_host(
176176

177177
for ip in addrs {
178178
if matches!(family, 4 | 0) {
179-
if let Ok(ipv4) = Ipv4Addr::from_str(&ip.to_string()) {
180-
return Ok((ipv4.to_string(), 4));
179+
if let Ok(ipv4) = SocketAddrV4::from_str(&ip.to_string()) {
180+
return Ok((ipv4.ip().to_string(), 4));
181181
}
182182
}
183183
if matches!(family, 6 | 0) {
184-
if let Ok(ipv6) = Ipv6Addr::from_str(&ip.to_string()) {
185-
return Ok((ipv6.to_string(), 6));
184+
if let Ok(ipv6) = SocketAddrV6::from_str(&ip.to_string()) {
185+
return Ok((ipv6.ip().to_string(), 6));
186186
}
187187
}
188188
}

modules/llrt_dns/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ fn lookup<'js>(ctx: Ctx<'js>, hostname: String, args: Rest<Value<'js>>) -> Resul
2020
.or_throw_msg(&ctx, "Callback parameter is not a function")?;
2121

2222
ctx.clone().spawn_exit(async move {
23-
match lookup_host(&hostname, args_iter.next())
24-
.await
25-
.or_throw(&ctx)
26-
{
23+
match lookup_host(&hostname, args_iter.next()).await {
2724
Ok((address, family)) => {
2825
() = cb.call((Null.into_js(&ctx), address, family))?;
2926
Ok::<_, Error>(())

0 commit comments

Comments
 (0)