Skip to content

Commit

Permalink
Merge pull request #5533 from stacks-network/fix/dns-lookup-burnchain…
Browse files Browse the repository at this point in the history
…-config

update peer host to parse dns instead of ip
  • Loading branch information
wileyj authored Dec 20, 2024
2 parents 0ee5d7c + 0ada390 commit 2e65928
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions stackslib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,21 +1500,15 @@ impl BurnchainConfigFile {
.unwrap_or(default_burnchain_config.commit_anchor_block_within),
peer_host: match self.peer_host.as_ref() {
Some(peer_host) => {
// Using std::net::LookupHost would be preferable, but it's
// unfortunately unstable at this point.
// https://doc.rust-lang.org/1.6.0/std/net/struct.LookupHost.html
let mut sock_addrs = format!("{peer_host}:1")
format!("{}:1", &peer_host)
.to_socket_addrs()
.map_err(|e| format!("Invalid burnchain.peer_host: {e}"))?;
let sock_addr = match sock_addrs.next() {
Some(addr) => addr,
None => {
return Err(format!(
"No IP address could be queried for '{peer_host}'"
));
}
};
format!("{}", sock_addr.ip())
.map_err(|e| format!("Invalid burnchain.peer_host: {}", &e))?
.next()
.is_none()
.then(|| {
return format!("No IP address could be queried for '{}'", &peer_host);
});
peer_host.clone()
}
None => default_burnchain_config.peer_host,
},
Expand Down

0 comments on commit 2e65928

Please sign in to comment.