This is a follow-up of #28155 motivated by #28155 (review)
Rationale
Prior to this, when establishing a network connection via CConnman::ConnectNode
, if the connection needed address resolution, a single address would be picked at random from the resolved addresses and our node would try to connect to it. However, this would lead to the behavior of ConnectNode
being unpredictable when the address was resolved to various ips (e.g. the address resolving to IPv4 and IPv6, but we only support one of them).
This patches the aforementioned behavior by going over all resolved IPs until a valid one is found or until we exhaust them.