Prevent duplicate connections when dialing a multiaddr without a peer id
If we dial a multiaddr without a peer id (e.g. /dns/example.com), and we exchange peer IDs with the remote, if we already have a non-circuit relay connection to that peer, the connection manager should close the new connection and return the existing connection.
At the moment we end up with multiple connections to the same peer which wastes resources.
Could this be handled by the transports that initiate connections via a relayed connection? They would cleanup the connection after the direct connection is established.
The issue of preventing duplicate connections to the same multiaddr looks like it was handled by https://github.com/libp2p/js-libp2p/commit/0c5957836d1416566f18233f58c92e7db6ab5525#diff-f67bf5a2d5ca417004f9cab5d20bb74d754a6a96cf4e4df6cf540d9a62388090R533-R540 two days after this issue was opened.
I'd be happy to work on a PR for a separate issue that addresses closing indirect connections used to open direct connections.