Skip to content

Commit c05569f

Browse files
committed
update peer host to parse dns instead of ip
1 parent 160b495 commit c05569f

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

testnet/stacks-node/src/config.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,21 +1482,15 @@ impl BurnchainConfigFile {
14821482
.unwrap_or(default_burnchain_config.commit_anchor_block_within),
14831483
peer_host: match self.peer_host.as_ref() {
14841484
Some(peer_host) => {
1485-
// Using std::net::LookupHost would be preferable, but it's
1486-
// unfortunately unstable at this point.
1487-
// https://doc.rust-lang.org/1.6.0/std/net/struct.LookupHost.html
1488-
let mut sock_addrs = format!("{peer_host}:1")
1485+
format!("{}:1", &peer_host)
14891486
.to_socket_addrs()
1490-
.map_err(|e| format!("Invalid burnchain.peer_host: {e}"))?;
1491-
let sock_addr = match sock_addrs.next() {
1492-
Some(addr) => addr,
1493-
None => {
1494-
return Err(format!(
1495-
"No IP address could be queried for '{peer_host}'"
1496-
));
1497-
}
1498-
};
1499-
format!("{}", sock_addr.ip())
1487+
.map_err(|e| format!("Invalid burnchain.peer_host: {}", &e))?
1488+
.next()
1489+
.is_none()
1490+
.then(|| {
1491+
return format!("No IP address could be queried for '{}'", &peer_host);
1492+
});
1493+
peer_host.clone()
15001494
}
15011495
None => default_burnchain_config.peer_host,
15021496
},

0 commit comments

Comments
 (0)