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

tls / noise: prefer the client's muxer preferences #1888

Merged
merged 2 commits into from
Nov 16, 2022

Conversation

marten-seemann
Copy link
Contributor

As the integration test (#1887) has revealed, TLS and Noise both selected the muxer according to the server's preferences, whereas the multistream negotiation selects according to the client's preferences. This PR changes TLS' and Noise's behavior to match the multistream behavior.

Since TLS' ALPN selection algorithm also selects according to the server's preferences, we have to play a little trick to overwrite that behavior.

Copy link
Collaborator

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

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

one nit about the var names, but otherwise lgtm

p2p/security/noise/transport.go Outdated Show resolved Hide resolved
for _, proto := range info.SupportedProtos {
for _, m := range muxers {
if m == proto {
config.NextProtos = []string{proto}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't we have to append the "libp2p" ALPN here? (It seems like were doing that below? with config.NextProtos = append(muxers, config.NextProtos...)). I'm pretty sure this doesn't matter, since we know the client supports the ALPN we set here. So maybe just a comment would be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically we have to, but we can short-circuit it, since we know that we'll select the muxer. I'll add a comment.

@marten-seemann marten-seemann force-pushed the early-muxer-negotiation-preferences branch from f9d777a to e047c22 Compare November 16, 2022 21:16
@marten-seemann marten-seemann force-pushed the early-muxer-negotiation-preferences branch from e047c22 to 0957a9d Compare November 16, 2022 22:10
@marten-seemann marten-seemann merged commit 090a084 into master Nov 16, 2022
@marten-seemann marten-seemann deleted the early-muxer-negotiation-preferences branch November 17, 2022 00:55
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.

2 participants