diff --git a/chia/server/reconnect_task.py b/chia/server/reconnect_task.py index df9b2b7b374c..7a3ec1515082 100644 --- a/chia/server/reconnect_task.py +++ b/chia/server/reconnect_task.py @@ -9,7 +9,11 @@ def start_reconnect_task(server: ChiaServer, peer_info_arg: PeerInfo, log, auth: """ Start a background task that checks connection and reconnects periodically to a peer. """ - peer_info = PeerInfo(socket.gethostbyname(peer_info_arg.host), peer_info_arg.port) + # If peer_info_arg is already an address, use it, otherwise resolve it here. + if peer_info_arg.is_valid(): + peer_info = peer_info_arg + else: + peer_info = PeerInfo(socket.gethostbyname(peer_info_arg.host), peer_info_arg.port) async def connection_check(): while True: diff --git a/chia/timelord/timelord_launcher.py b/chia/timelord/timelord_launcher.py index 637423f4396c..14d46cc69e7b 100644 --- a/chia/timelord/timelord_launcher.py +++ b/chia/timelord/timelord_launcher.py @@ -8,9 +8,11 @@ from typing import Dict, List import pkg_resources +from chia.types.peer_info import PeerInfo from chia.util.chia_logging import initialize_logging from chia.util.config import load_config from chia.util.default_root import DEFAULT_ROOT_PATH +from chia.util.ints import uint16 from chia.util.setproctitle import setproctitle active_processes: List = [] @@ -49,7 +51,11 @@ async def spawn_process(host: str, port: int, counter: int): try: dirname = path_to_vdf_client.parent basename = path_to_vdf_client.name - resolved = socket.gethostbyname(host) + check_addr = PeerInfo(host, uint16(port)) + if check_addr.is_valid(): + resolved = host + else: + resolved = socket.gethostbyname(host) proc = await asyncio.create_subprocess_shell( f"{basename} {resolved} {port} {counter}", stdout=asyncio.subprocess.PIPE, diff --git a/chia/wallet/wallet_node.py b/chia/wallet/wallet_node.py index f5eccdec92bb..f1c2f601d4d8 100644 --- a/chia/wallet/wallet_node.py +++ b/chia/wallet/wallet_node.py @@ -395,7 +395,12 @@ class WalletNode: self.config["full_node_peer"]["port"], ) peers = [c.get_peer_info() for c in self.server.get_full_node_connections()] - full_node_resolved = PeerInfo(socket.gethostbyname(full_node_peer.host), full_node_peer.port) + # If full_node_peer is already an address, use it, otherwise + # resolve it here. + if full_node_peer.is_valid(): + full_node_resolved = full_node_peer + else: + full_node_resolved = PeerInfo(socket.gethostbyname(full_node_peer.host), full_node_peer.port) if full_node_peer in peers or full_node_resolved in peers: self.log.info(f"Will not attempt to connect to other nodes, already connected to {full_node_peer}") for connection in self.server.get_full_node_connections():