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

feat: support sni tuple in wss multiaddr #39

Merged
merged 4 commits into from
Oct 28, 2024

Conversation

SgtPooki
Copy link
Contributor

@SgtPooki SgtPooki commented Oct 25, 2024

Not sure whether we want these addrs to appear in exactWSS or goodWSS

When testing ipfs/service-worker-gateway#405, I noticed that js-libp2p was failing to calculate whether multiaddrs were dialable or not.

We received two provider multiaddrs for a CID:

[
    "/ip4/147.75.87.65/tcp/4002/tls/sni/147-75-87-65.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/ws",
    "/ip6/2604:1380:4601:f600::1/tcp/4002/tls/sni/2604-1380-4601-f600--1.k51qzi5uqu5dhb03btheentd9nmkaygwm4q3tfrm596s5thf1u87bc7gq0m2ia.libp2p.direct/ws"
]

the libp2p.direct addrs were being filtered out in https://github.com/libp2p/js-libp2p/blob/717731e49a40142164af6c5c5703f0cad32edbe5/packages/transport-websockets/src/index.ts#L202-L215 and resulting in an error in the console: libp2p:connection-manager:dial-queue:trace error calculating if multiaddr(s) were dialable +4m NoValidAddressesError: The dial request has no valid addresses

src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@achingbrain
Copy link
Member

achingbrain commented Oct 25, 2024

Not sure whether we want these addrs to appear in exactWSS or goodWSS

The difference is, exact addresses have no trailing tuples, good addresses can have them.

So this is an exact WSS multiaddr:

/ip4/123.123.123.123/tcp/443/tls/ws

This is not:

/ip4/123.123.123.123/tcp/443/tls/ws/p2p/QmRelay/p2p-circuit/p2p/QmTarget

Both would be matched by the WebSocketSecure matcher, but only the first would be matched by the WebSocketSecure exact matcher.

When dialing we use exact matchers to decide which transport handles the address, so the first would be handled by the WebSocket transport, the second by the CircuitRelay transport (which might then delegate to the WebSocket transport to perform the initial dial).

@SgtPooki SgtPooki changed the title feat: support libp2p.direct multiaddr feat: support libp2p.direct wss multiaddr Oct 25, 2024
@achingbrain achingbrain changed the title feat: support libp2p.direct wss multiaddr feat: support sni tuple in wss multiaddr Oct 28, 2024
@achingbrain achingbrain merged commit 2b687b4 into main Oct 28, 2024
19 checks passed
@achingbrain achingbrain deleted the feat/support-libp2p-direct-multiaddr branch October 28, 2024 16:21
github-actions bot pushed a commit that referenced this pull request Oct 28, 2024
## [1.4.0](v1.3.0...v1.4.0) (2024-10-28)

### Features

* support sni tuple in wss multiaddr ([#39](#39)) ([2b687b4](2b687b4))
Copy link

🎉 This PR is included in version 1.4.0 🎉

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.

3 participants