From c05569f097db45138f4d6fee478a9131dc1d1c1f Mon Sep 17 00:00:00 2001 From: ASuciuX Date: Wed, 4 Dec 2024 20:17:47 +0200 Subject: [PATCH] update peer host to parse dns instead of ip --- testnet/stacks-node/src/config.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/testnet/stacks-node/src/config.rs b/testnet/stacks-node/src/config.rs index 785ce057e5..e58bd2b848 100644 --- a/testnet/stacks-node/src/config.rs +++ b/testnet/stacks-node/src/config.rs @@ -1482,21 +1482,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, },