p2panda / aquadoggo

Node for the p2panda network handling validation, storage, aggregation and replication
GNU Affero General Public License v3.0
69 stars 5 forks source link

Introduce `PeerAddress` struct for improved address resolution patterns #621

Closed sandreae closed 2 months ago

sandreae commented 2 months ago

In all public aquadoggo configuration APIs peers can be addressed by IP address or domain name, in the case of the later, before making a connection attempt we need to do a DNS lookup to get the correct socket address. When the node is offline then we want to silently ignore failed lookups, just log the attempt and continue. Currently we only perform lookup when a node starts and we parse the configuration file, but later we want to introduce redials of relays and direct nodes, this will require us to perform the DNS lookup later (it may have failed on startup).

This PR just introduces a new struct PeerAddress with two methods socket and quic_multiaddr which help us handle still unresolved peer addresses. When socket is called and successfully resolves the peer address string to a SocketAddr the result is cached and directly used on later calls in order to avoid unnecessary DNS lookups.

closes: #613

📋 Checklist