You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(iroh-net): Implement websocket protocol upgrade in iroh-relay (#2387)
Implements the `websocket` protocol upgrade in iroh-relay and changes
`iroh-net` clients to connect with `websocket` instead of `iroh derp
http`.
State of this is:
- `cargo test -p iroh-net` runs green
- websocket on the relay is supported
- backwards compatibility is tested
- the client also supports connecting using websockets
- (but we're forced to use tungstenites connection establishment, no
custom `MaybeTlsStream`.)
- It decides this via the URL scheme (`ws(s)://` vs. `http(s)://`)
TODO:
- [x] Enumify the client so it's possible to keep using the old relay
protocol
- [x] Cleanup!
- [x] Some perf TODOs in the server, less copying.
- [x] Update documentation (e.g. `local_addr` having another case being
`None`)
- [x] Add metrics for websocket-accept & derp-accept counts
- [x] Snapshot tests (using `parse_hexdump`) for "new" wire format
## Description
- Supports clients connecting to iroh-relay with websockets & running
the derp protocol over websocket `Binary` msgs.
- Adds support for the relay answering `Upgrade: websocket` headers
instead of `Upgrade: iroh derp http` appropriately.
- Adds support for `ClientBuilder` to dial via websockets, if the relay
URL is set with a `ws`/`wss` URL scheme.
## Breaking Changes
- Not in the protocol: The old HTTP upgrade & protocol should still be
supported. There's tests to ensure this.
- `Client::local_addr` will now also return `None`, if one connected
using websockets.
- `iroh_net::relay::http::ClientError`: Added a variant `WebsocketError`
for errors when establishing a connection using websockets.
## Notes & open questions
Closes#2370
## Change checklist
- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
0 commit comments