Skip to content

Commit

Permalink
Merge pull request #3900 from waynr/lib/virtual-net/fix-tokio-net-loo…
Browse files Browse the repository at this point in the history
…kup_host-call

lib/virtual-net: tokio::net::lookup_host requires host:port format
  • Loading branch information
waynr authored May 24, 2023
2 parents e62efef + 20f6189 commit 42c2e2c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/virtual-net/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ impl VirtualNetworking for LocalNetworking {
port: Option<u16>,
dns_server: Option<IpAddr>,
) -> Result<Vec<IpAddr>> {
tokio::net::lookup_host(host)
let host_to_lookup = if host.contains(':') {
host.to_string()
} else {
format!("{}:{}", host, port.unwrap_or(0))
};
tokio::net::lookup_host(host_to_lookup)
.await
.map(|a| a.map(|a| a.ip()).collect::<Vec<_>>())
.map_err(io_err_into_net_error)
Expand Down

0 comments on commit 42c2e2c

Please sign in to comment.