Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(iroh): Enable applications to establish 0-RTT connections (#3163)
## Description Implements necessary APIs to make use of 0-RTT QUIC connections. 0-RTT allows you to skip a round-trip in case you have connected to a known endpoint ahead of time, and stored the given TLS session ticket. With this PR, we by default will cache up to 8 session tickets per endpoint you connect to, and remember up to 32 endpoints maximum. This cache only lives in-memory. We might add customization to the `EndpointBuilder` in the future to allow for customizing this cache (allowing you to persist it), but that obviously has security implications, so will need careful consideration. This PR enables using 0-RTT via the `Endpoint::connect_with_opts` function, which - unlike `Endpoint::connect` - returns a `Connecting`, a state prior to a full `Connection`. By calling `Connecting::into_0rtt` you can attempt to turn this connection into a full 0-RTT connection. However, security caveats apply. See that function's documentation for details. Migration guide: ```rs let connection = endpoint.connect_with(node_addr, alpn, transport_config).await?; ``` to ```rs let connection = endpoint.connect_with_opts( node_addr, alpn, ConnectOptions::new().with_transport_config(transport_config), ) .await? .await?; // second await for Connecting -> Connection ``` Closes #3146 ## Breaking Changes - `iroh::Endpoint::connect_with` was removed, and `iroh::Endpoint::connect_with_opts` was added instead, but returning an `iroh::endpoint::Connecting` instead of an `iroh::endpoint::Connection`, allowing use of QUIC's 0-RTT feature. - `iroh::endpoint::Connection::into_0rtt` now returns `iroh::endpoint::ZeroRttAccepted` (among other things), instead of `iroh_quinn::ZeroRttAccepted`. This wrapper is equivalent in functionality, but makes sure we're not depending on API-breaking changes in quinn and can keep a discovery task alive for as long as needed, until a connection is established. ## Change checklist - [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.
- Loading branch information