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

Add get_address_proto to handle trailing "tls/ws" in multiaddr #2487

Closed
wants to merge 6 commits into from

Conversation

jochasinga
Copy link
Contributor

Before returning Ws protocol when hitting the last trailing /ws in a multiaddr,
check to see if the next path segment is /tls. If it is, then return Wss instead.
This addresses #2449 the deprecated /wss specifier for the new /tls/ws in the spec.

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Thanks!

Some ideas for how this could be improved :)

transports/websocket/src/framed.rs Outdated Show resolved Hide resolved
@tomaka
Copy link
Member

tomaka commented Feb 8, 2022

I guess this is a first step 👍 , but for #2449 to be finished we need a couple more changes, such as producing /tls/ws when receiving an incoming connection. Ultimately Protocol::Wss shouldn't be used except specifically for backwards compatibility.

@jochasinga
Copy link
Contributor Author

jochasinga commented Feb 8, 2022

I guess this is a first step 👍 , but for #2449 to be finished we need a couple more changes, such as producing /tls/ws when receiving an incoming connection. Ultimately Protocol::Wss shouldn't be used except specifically for backwards compatibility.

Could you elaborate on those two points @tomaka ?

@jochasinga
Copy link
Contributor Author

@tomaka or @thomaseizinger some help on finishing this up?

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

I can't comment on what @tomaka said unfortunately. I am not familiar enough with the code here.

transports/websocket/src/framed.rs Outdated Show resolved Hide resolved
@mxinden
Copy link
Member

mxinden commented Apr 6, 2022

I am not particularly familiar with this code. @tomaka your input would be more helpful here.

In regards to above comment on this still missing some parts, if I am not mistaken the code below would append a ws or wss, but not a tls/ws:

local_addr = local_addr.with(proto.clone());
remote_addr = remote_addr.with(proto.clone());

Is that of some help @jochasinga?

@thomaseizinger thomaseizinger added the need/author-input Needs input from the original author label Nov 2, 2022
Before returning Ws protocol when hitting the last trailing `/ws` in a multiaddr,
check to see if the next path segment is `/tls`. If it is, then return Wss instead.
This addresses libp2p#2499 the deprecated `/wss` specifier for the new `/tls/ws` in the spec.
This was from the last test which had the typo and happily passed.
…addr into it

Previously, the function borrow a mutable multiaddr reference from the caller without
returning it. To make the API simpler, now it's moved into the function and the mutated
multiaddr is returned as part of the triplet tuples.
Refactor get_address_proto into a tuple-matching statement and use
`Iter::last()` to peek into the next protocol segment instead of cloning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/author-input Needs input from the original author Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants