-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(dcutr): always check for relayed connection first #3982
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4ed1427
Fix DCUtR NetworkBehavior's established connection handler
arpankapoor bf1dfce
Use early return
arpankapoor 770e9d0
Assert that outgoing_direct_connection_attempts entry was removed
arpankapoor 527371e
Fix failing test
arpankapoor 3b444eb
Add back removal of outgoing_direct_connection_attempts entry
arpankapoor 5e9e0a3
Add assert on Listener for outgoing_direct_connection_attempts entry …
arpankapoor d1aba5f
Return dummy handler directly in inbound handler
arpankapoor b3c0996
Fix clippy warning
arpankapoor 5948aee
Add comment
arpankapoor 981735b
Merge branch 'master' into dcutr-fix
thomaseizinger bf8d1b6
Merge branch 'master' into dcutr-fix
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this can ever be hit actually. In hole-punching, we cannot for sure tell which inbound connection was the one that the remote achieved through hole punching.
Plus, all this state tracking here uses
ConnectionId
s that are created as part of dialing, i.e. outbound connections.So unless I am missing something, this function can be reduced to always return a
dummy::ConnectionHandler
for non-relayed connections.@mxinden Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I agree with your assessment. I'll make this change after @mxinden's comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right @thomaseizinger.
For what it is worth, likely my train of thought that ended up with the code above:
In
NetworkBehaviour::on_connection_handler_event
onOutboundConnectNegotiated
we trigger aDial
withrole_override()
(i.e.as_listener
) and then insert themaybe_direct_connection_id
from theDialOpts
intoself.direct_to_relayed_connections
.rust-libp2p/protocols/dcutr/src/behaviour_impl.rs
Lines 379 to 395 in d4c4078
On success this would be reported to the
Behaviour
viaNetworkBehaviour::handle_established_outbound_connection
and not as assumed here inNetworkBehaviour::handle_established_inbound_connection
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding an
assert
here, thatconnection_id
is not inself.direct_to_relayed_connections
?