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(SwarmBuilder): prioritize relay, then websocket, then any other #4672

Merged
merged 6 commits into from
Oct 18, 2023

Conversation

thomaseizinger
Copy link
Contributor

Description

There is a niche case where dialing a relay address does not work if the other transport is a DNS transport. By composing the relay transport first, we avoid this issue.

Notes & open questions

I am not sure if this is the fully correct fix.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@mxinden
Copy link
Member

mxinden commented Oct 18, 2023

@thomaseizinger can you expand on your use-case? Why do you pass a DNS transport via with_other_transport and not via with_dns? DNS needs special handling, given that it never returns Err(MultiaddrNotSupported), but instead, errors later on, asynchronously. That is why it always has to come last.

Ok(async move {

Yes, the proposed patch here is a solution. Though I wonder whether we can do better.

@thomaseizinger
Copy link
Contributor Author

Try https://github.com/libp2p/rust-libp2p/blob/master/examples/dcutr/src/main.rs. It doesn't work at the moment :)

@mxinden
Copy link
Member

mxinden commented Oct 18, 2023

Ah, yes, that makes a lot of sense. Let's go with your patch. Also, let's move with_relay after with_websocket just in case someone wants to establish a relayed connection over a websocket connection.

I will push another commit shortly.

Thus allowing a relayed connection over a websocket connection.
@mxinden mxinden changed the title fix(libp2p): compose relay transport before other transports fix(SwarmBuilder): prioritize relay, then websocket, then any other transport Oct 18, 2023
@mxinden mxinden changed the title fix(SwarmBuilder): prioritize relay, then websocket, then any other transport fix(SwarmBuilder): prioritize relay, then websocket, then any other Oct 18, 2023
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Thomas for catching this

@thomaseizinger
Copy link
Contributor Author

@mxinden Meta-question: I thought we use the "scope" of conventional commits for the crate that we are changing, which is why I originally named it as fix(libp2p). Curious to hear what you think.

@mxinden
Copy link
Member

mxinden commented Oct 18, 2023

No strong opinion. To me SwarmBuilder was a more descriptive scope. I am assuming that most folks working on rust-libp2p know where the new SwarmBuilder is located, namely in libp2p. Happy to restrict the scope to crates only. Thoughts?

@thomaseizinger
Copy link
Contributor Author

No strong opinion. To me SwarmBuilder was a more descriptive scope. I am assuming that most folks working on rust-libp2p know where the new SwarmBuilder is located, namely in libp2p. Happy to restrict the scope to crates only. Thoughts?

It is the better trade-off I think, despite the ambiguity with the old SwarmBuilder.

@mxinden mxinden added the internal-change Pull requests that make internal changes to crates and thus don't need to include a changelog entry. label Oct 18, 2023
@mxinden
Copy link
Member

mxinden commented Oct 18, 2023

SwarmBuilder is not yet released, thus adding the internal-changes label.

@thomaseizinger
Copy link
Contributor Author

SwarmBuilder is not yet released, thus adding the internal-changes label.

Should we name it allow-no-changelog perhaps?

@mxinden
Copy link
Member

mxinden commented Oct 18, 2023

SwarmBuilder is not yet released, thus adding the internal-changes label.

Should we name it allow-no-changelog perhaps?

I am fine either way.

@mergify mergify bot merged commit 8df38eb into master Oct 18, 2023
71 of 72 checks passed
@mergify mergify bot deleted the fix/relay-first branch October 18, 2023 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal-change Pull requests that make internal changes to crates and thus don't need to include a changelog entry. send-it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants