Open
Conversation
Extract the connection logic into `do_connect_peer_internal` and have `do_connect_peer` act as a thin wrapper that always calls `propagate_result_to_subscribers` with the result. This removes the need to manually propagate at every error site, making the code less error-prone. Co-Authored-By: HAL 9000
|
👋 Thanks for assigning @tankyleo as a reviewer! |
tankyleo
reviewed
Mar 30, 2026
tankyleo
reviewed
Mar 31, 2026
Contributor
tankyleo
left a comment
There was a problem hiding this comment.
LGTM feel free to squash
src/connection.rs
Outdated
| had_failures = true; | ||
| log_debug!( | ||
| self.logger, | ||
| "Failed to connect to peer {}@{} via resolved proxy address {}, trying next address.", |
Contributor
There was a problem hiding this comment.
nit: we won't be trying a next address if we are at the end of the iteration, here and below
Collaborator
Author
There was a problem hiding this comment.
Okay, now dropped the "trying next address part". Not sure it's worth to further complicate the logic just to be precise regarding whether we try one more, especially given we'll be constantly retrying all connections anyways.
Replace the synchronous, blocking `std::net::ToSocketAddrs::to_socket_addrs()` calls with async `tokio::net::lookup_host` to avoid blocking the tokio runtime during DNS resolution. Additionally, instead of only using the first resolved address, we now iterate over all resolved addresses and try connecting to each in sequence until one succeeds. This improves connectivity for hostnames that resolve to multiple addresses (e.g., dual-stack IPv4/IPv6). Co-Authored-By: HAL 9000
d673d15 to
105f835
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, we used
std::net::ToSocketAddrsfor DNS resolution. While this generally worked, we also used the blockingto_socket_addrscall in async contexts, blocking a runtime task during resolution. This isn't great, so here we switch to usetokio::net::lookup_hostfor async resolution.