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: Rewrite to interpret multiaddr from right to left #120

Merged
merged 6 commits into from
May 19, 2023

Conversation

MarcoPolo
Copy link
Contributor

@MarcoPolo MarcoPolo commented Mar 4, 2023

I wanted to support /tls/ws, /tls/http, and /tls/sni/example.com/http. Unfortunately the existing code interprets these multiaddrs left to right in a reduce loop. These multiaddrs (and multiaddrs in general) need to be parsed right to left. This refactors the code to so that it is interpreted right to left.

It's a bit verbose, but straightforward.

This is somewhat blocked on multiformats/js-multiaddr#312 (Not strictly blocked, but would be good to bump the dep when that is merged).

This is needed because js-libp2p-websockets uses this library, and without this we can't dial addresses that use /tls/ws or /tls/sni/example.com/ws...

@MarcoPolo MarcoPolo requested a review from achingbrain March 4, 2023 02:16
@MarcoPolo
Copy link
Contributor Author

Tests will fail until multiformats/js-multiaddr#312 is merged

@achingbrain achingbrain changed the title Rewrite to interpret multiaddr from right to left fix: Rewrite to interpret multiaddr from right to left Mar 6, 2023
Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

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

LGTM, just a small change needed.

Also, do we need to add anything to handle the snazzy new webtransport/webrtc/webrtc-direct transports?

src/index.ts Outdated Show resolved Hide resolved
@MarcoPolo MarcoPolo requested a review from achingbrain May 17, 2023 18:36
@MarcoPolo
Copy link
Contributor Author

Also, do we need to add anything to handle the snazzy new webtransport/webrtc/webrtc-direct transports?

No, they don't use this library.

@achingbrain achingbrain merged commit 681d4e3 into master May 19, 2023
@achingbrain achingbrain deleted the marco/rewrite branch May 19, 2023 09:05
github-actions bot pushed a commit that referenced this pull request May 19, 2023
## [9.0.5](v9.0.4...v9.0.5) (2023-05-19)

### Bug Fixes

* Rewrite to interpret multiaddr from right to left ([#120](#120)) ([681d4e3](681d4e3))
@github-actions
Copy link

🎉 This PR is included in version 9.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants