-
Notifications
You must be signed in to change notification settings - Fork 999
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
feat(swarm)!: Allow NetworkBehaviour
s to manage incoming connections
#3099
Closed
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d501019
Introduce `NetworkBehaviour::DialPayload`
thomaseizinger 77c85f6
WIP Migrate production code
thomaseizinger 118ffb6
Deprecate `new_handler`
thomaseizinger 377c351
WIP: Completely remove `IntoConnectionHandler`
thomaseizinger 9972eb4
Set supported protocols upon connection establishment
thomaseizinger fb9cdbc
Remove TODOs
thomaseizinger a96780d
Fix bad boolean logic
thomaseizinger 3c9d98e
Merge branch 'master' into 2824-remove-into-connection-handler
thomaseizinger 900edef
Fix gossipsub tests
thomaseizinger d1eea3a
Fix clippy warning
thomaseizinger 98bf927
Update docs
thomaseizinger 1cef941
Reduce diff
thomaseizinger ca3ef3e
Fix clippy errors
thomaseizinger a7f0685
Merge branch 'master' into 2824-remove-into-connection-handler
thomaseizinger d95b038
Update swarm/src/behaviour.rs
thomaseizinger edbbe41
Add changelog entry
thomaseizinger fef8d85
Merge branch 'master' into 2824-remove-into-connection-handler
thomaseizinger a942248
Remove unnecessary bounds
thomaseizinger 0578134
Remove old example
thomaseizinger f7def2b
fmt
thomaseizinger a5a728b
Make `new_handler` fallible
thomaseizinger 27e1b2d
Merge branch 'master' into 2824-remove-into-connection-handler
thomaseizinger 19348e9
Allow each `NetworkBehaviour` to have their own `ConnectionDenied` re…
thomaseizinger 9c55601
Merge branch 'master' into 2824-remove-into-connection-handler
thomaseizinger 527eeda
Merge branch 'master' into 2824-remove-into-connection-handler
thomaseizinger a269e9d
Revert "Allow each `NetworkBehaviour` to have their own `ConnectionDe…
thomaseizinger dcb4f96
Always box cause for denied connection
thomaseizinger 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
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.
Should we replace this example? Now that
new_handler
gives you aPeerId
, I think it is quite easy to realize that you can store data for a future connection in the behaviour and just pass it into the handler here.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.
Say there are two
NetworkBehaviour
implementations, each requesting a new connection to a new peer. In such case, whenNetworkBehaviour::inject_connection_established
is called, neither of them knows whether this new connection corresponds to their dial request.We could still allow the user to provide user data via
DialOpts
. For the case ofSwarm::dial
andNetworkBehaviour::inject_dial_failure
we could wrap this in anOption
.I am not sure whether we need to design for the above race condition. Your proposal might be just fine. What do folks think?
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.
In
ipfs-embed
I validate advertised peer addresses by dialling them — and closing such connections upon success. This is only reliably possible if I can detect whether the connection resulted from my own dialling attempt. OTOH, another cause may have resulted in dialling that same peer with that same address for other reasons, which would then possibly have said “nah, attempt is already underway”. But all of this would happen in addition to existing connections, so it might not be a huge problem.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.
Do you need to actively close them? Assuming reasonable
keep_alive
implementations of yourConnectionHandler
s, the connection should get closed automatically if it is not in use.Can this be expressed with
PeerCondition::NotDialing
?Note that
new_handler
also gives you access toConnectedPoint
. So in addition to storing data in your behaviour based onPeerId
, you could also index it by the dialed address.new_handler
being called for an address you wanted to validate IS the validation that a connection was made to this address. If you have a dedicatedAddressValidationBehaviour
, that behaviour could then straight up deny that connection which instantly closes it again.