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-relay)!: Implement new handshake protocol, refactor frame types (#3331)
## Description
This PR changes the iroh relay handshake and relaying protocol.
The main goals are:
- Actually authenticate the client by verifying a signed challenge
(previously only the client info was signed)
- We also allow using TLS extracted keying material as the subject to
sign and sending it in an HTTP header, if that is available. When this
works (it does so most of the time), it's 1RTT faster.
- Use a better encoding for messages (we now use QUIC varints for frame
type, use websocket framing for the protocol)
- Remove outdated and unused frames (KeepAlive, NotePreferred)
There's also some secondary changes:
- Conceptually, the relay handshake and relaying protocols are now
split: There's a `protos::handshake` module for the handshake, and a
`protos::relay` for the send/recv protocol.
- I've refactored the streams we have in iroh-relay. We now use this
stack:
- On the client, we establish TLS streams using
`MaybeTlsStream<ProxyStream>`. `MaybeTlsStream` gives us the TLS
handshake and `ProxyStream` gives us HTTPS proxy support.
- On the server we establish rate-limited TLS streams using
`RateLimit<MaybeTlsStream>`.
- On top of these two, we stack `WsBytesFramed`, which internally uses
`tokio_websockets::WebSocketStream` natively and on the server and
`ws_stream_wasm::WsStream` in browsers. This wrapper does the websocket
framing and translates opaque `Bytes` messages into websocket bytes
frames.
- This `WsBytesFramed` is then directly used with the `handshake`
protocol on the server and client side.
- For the `send_recv` protocol, we then upgrade the server side to
`RelayedStream` and the client side to the `Conn` type.
- Instead of having `Frame`, `ReceivedMessage` and `SendMessage` as
types, we now only have `RelayToClientMsg` and `ClientToRelayMsg` for
the send/recv protocol.
## Breaking Changes
In iroh:
- Connections to older relays don't work anymore.
In iroh-relay:
- Removed `iroh_relay::client::SendMessage` and
`iroh_relay::client::ReceivedMessage` in favor of `ClientToRelayMsg` and
`RelayToClientMsg` respectively.
- `impl Stream for Client` now produces `RelayToClientMsg` instead of
`ReceivedMessage`
- `Client` now `impl Sink<ClientToRelayMsg>` instead of `impl
Sink<SendMessage>`
- Removed `ClientBuilder::is_prober`
- Moved `protos::relay::FrameType` to `protos::common::FrameType` and
adjusted frame types to those of the current set of protocols
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
0 commit comments