Skip to content
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: prevent duplicate connections to multiaddr #2734

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tabcat
Copy link
Contributor

@tabcat tabcat commented Sep 29, 2024

Title

fix: prevent duplicate connections to multiaddr

Description

After opening a new connection, check if there is an existing connection
to the same peer. If the existing connection is not limited or the new
connection is also limit, return the existing connection.

This will prevent multiple connections to the same peer in cases where
the multiaddr being dialed does not contain a peer id.

Notes & open questions

Closes #2714

There is a small change from what was requested in the issue. An existing limited connection will be returned if the new connection is also limited.

Should conn.close() be awaited before returning the existing connection?

Where should a test for this be added?

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

After opening a new connection, check if there is an existing connection
to the same peer. If the existing connection is not limited or the new
connection is also limit, return the existing connection.

This will prevent multiple connections to the same peer in cases where
the multiaddr being dialed does not contain a peer id.
Checks that the dialer is returning existing connections to the same
peer when given a multiaddr without a peer id.
@tabcat
Copy link
Contributor Author

tabcat commented Oct 2, 2024

I've added two tests to check that the existing or new connection is returned appropriately.

@tabcat tabcat marked this pull request as ready for review October 2, 2024 14:22
@tabcat tabcat requested a review from a team as a code owner October 2, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent duplicate connections when dialing a multiaddr without a peer id
1 participant