-
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
core/src/transport: Add Transport::dial_as_listener
#2363
Merged
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f18a0bb
core/src/transport: Add `as_listener` to `Transport::dial`
mxinden 63cc3b2
*: Document as_listener flag
mxinden c005b0d
*: Wrap as_listener bool in newtype DialAsListener
mxinden cbdfd85
*: Use Endpoint and role_override
mxinden 1800084
transports/tcp/src/lib: Fix dial call
mxinden a08d2f9
Merge branch 'libp2p/master' into as-listener
mxinden 5d4d271
*: Run rust fmt
mxinden 0cbeab2
Merge branch 'libp2p/master' into as-listener
mxinden cd5e790
*: Add changelog entries
mxinden afd0620
Merge branch 'libp2p/master' into as-listener
mxinden af10530
*: Rename Transport::dial_with_role_override to dial_as_listener
mxinden 82fb3cb
protocols/autonat: Cover role_override on ConnectedPoint::Dialer
mxinden 618874c
protocols/relay/src/v2: Implement Transport::dial_as_listener
mxinden 17cc1b8
Merge branch 'master' into as-listener
mxinden 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
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
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
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
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
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
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
Oops, something went wrong.
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 introduced this newtype instead of passing a
bool
through the various layers.I like the fact that it (a) increases type safety and (b) carries its documentation. Unfortunately it is not particularly intuitive, nor idiomatic (never seen a newtype around a
bool
) nor convenient (e.g. seeif as_listener == false
).@thomaseizinger you usually have good ideas when it comes to idiomatic Rust. Any alternatives that come to your mind?
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.
What do you think of:
We could be even more descriptive and do:
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.
This is a good idea, especially as it does not introduce a new type. Though it does allow for duplication of information and thus potentially confusion?
PendingPoint::Dialer { role_override: Some(Endpoint::Dialer) }
is the same asPendingPoint::Dialer { role_override: None }
.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.
Note that this whole out-of-band role negotiation does not only concern upgrades, but some transport protocols as well. The TCP transport implementation does not require this information as it will open a simultaneous open TCP connection either way. But QUIC does. In the case of QUIC the listener sends a random-garbage packet instead of a connection-initiation packet.
https://github.com/libp2p/specs/blob/master/relay/DCUtR.md#the-protocol
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.
Back to your suggestion of
role_override
, how would the signatures ofNetwork::dial
andPeer::dial
look like?I find this descriptive but again confusing due to the duplication of information where
Some(Endpoint::Dialer)
is the same asNone
.