-
Notifications
You must be signed in to change notification settings - Fork 321
feat!: make Connection::remote_id and Connection::alpn infallible
#3556
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
Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3556/docs/iroh/ Last updated: 2025-11-04T13:19:27Z |
ab5d85a to
0bcfe81
Compare
|
Still some open questions around the server side of the ZeroRttConnection! |
|
Okay, this latest version has Besides bikeshedding the names I think we either go this route, or a route that combines both sides into |
- the `ZeroRttConnection` now contains the `ZeroRttAccepted` struct, and `into_connection` waits for the `ZeroRttAccepted` returns, before returning the `Connection` and the result of `ZeroRttAccepted`
…endpoint.rs` to `endpoint/connections.rs`
b4f81dd to
681e879
Compare
|
Separated everything about All structs are still exported from the |
matheus23
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the new API :) Infallible remote_id and ALPN are great!
Having a server and client version of ZeroRttConn is perfectly fine, perhaps I'd even extend that to Connecting (I wrote more about this in a comment).
Some comments and one thing to figure out (making 0-RTT work with ProtocolHandler).
…will always fail
…erting from a quinn connection to an iroh connection
6bdb78e to
b1c42ef
Compare
Connection::remote_id and Connection::alpn infallibleConnection::remote_id and Connection::alpn infallible
Description
This PR refactors the connection API to make
Connection::remote_id()andConnection::alpn()infallible. Previously, these methods could fail if called before the handshake completed or if the handshake data was unavailable. Now,Connectionguarantees that it represents a fully authenticated connection with verified remote identity and ALPN protocol, since it now can only be constructed after successful handshake completion and authentication, eliminating the need for fallible accessors.0-RTT API Improvements
The 0-RTT API has been restructured with clearer types and semantics:
Use
Incoming::acceptto return anAccepting. UseAccepting::into_0rttto return anIncomingZeroRttConnectionUse
Connecting::into_0rttto return aOutgoingZeroRttConnectionOutgoingZeroRttConnection: Represents client-side 0-RTT connections created viaConnecting::into_0rtt(). Allows sending 0-RTT data before the handshake completes. Callhandshake_completed()to get aZeroRttStatusindicating whether the 0-RTT data was accepted or rejected by the server.IncomingZeroRttConnection: Represents server-side 0-RTT/0.5-RTT connections created viaAccepting::into_0rtt(). Allows receiving 0-RTT data from clients or sending 0.5-RTT data before the handshake completes. Callhandshake_completed()to get a fully authenticatedConnection.ZeroRttStatusenum: Returned byOutgoingZeroRttConnection::handshake_completed()to indicate whether the server accepted or rejected the 0-RTT data:ZeroRttStatus::Accepted(Connection): 0-RTT data was accepted, streams opened before handshake remain validZeroRttStatus::Rejected(Connection): 0-RTT data was rejected, pre-handshake streams will error and data must be resentThese types replace the previous the previous version of
Connection& theZeroRttAcceptedtype and provide a more explicit API for handling 0-RTT connection states and outcomes.Error Handling
AuthenticationErrorduring the conversion between aquinn:Connection(which can exist before the handshake completes) and aniroh::Connection. This error may occur if the remote endpoint is not using the expected TLS cryptography or if the remote endpoint is a plain quinn connection. You may also see these errors after calling thehandshake_completedmethod onIncomingZeroRttConnectionorOutgoingZeroRttConnection, if the connection was closed before the handshake completed.ConnectingErrortype for errors during handshake completionBreaking Changes
irohchangedConnectError::Connection- fields changedAcceptError::Connection- fields changedAcceptError::MissingRemoteEndpointId- fields changedAcceptError::NotAllowed- fields changedAcceptError::User- fields changedConnecting::into_0rtt-> returnsResult<OutgoingZeroRttConnection, Connecting>removedProtocolHandler::on_connecting()removed - implementon_accepting()instead, which takesAcceptingrather thanConnectingDynProtocolHandler::on_connecting()removed - implementon_accepting()insteadiroh::endpoint::IncomingFuture- useAcceptinginsteadiroh::endpoint::ZeroRttAccepted- replaced by explicit 0-RTT connection types