Skip to content

Commit f3fd988

Browse files
authored
feat(iroh,iroh-relay)!: Use stride instead of custom split protocol, send ECN bits (#3389)
## Description Based on #3331 - Enable doing active queue management in relays in the future (we now send ECN bits with messages!) - Avoid doing our own packet merging & splitting, instead just forward quinn's `Transmit` format (bytes + optional stride) ## Breaking Changes The relay wire protocol changed: All relayed messages now contain at least an additional ECN byte. They *might* be accidentally compatible when GSO is not enabled, but they're likely not. This means this version of iroh can't connect to older relays or older clients on newer relays. - `ClientToRelayMsg::SendPacket` was removed in favor of `ClientToRelayMsg::Datagrams` - `RelayToClientMsg::ReceivedPacket` was removed in favor of `RelayToClientMsg::Datagrams` - `FrameType` has changed variants: - `SendPacket` and `RecvPacket` were removed - `ClientToRelayDatagram` and `ClientToRelayDatagramBatch` were added - `RelayToClientDatagram` and `RelayToClientDatagramBatch` were added ## 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. - [x] List all breaking changes in the above "Breaking Changes" section.
1 parent 3a1592a commit f3fd988

File tree

12 files changed

+516
-445
lines changed

12 files changed

+516
-445
lines changed

iroh-relay/src/client/conn.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ impl Sink<ClientToRelayMsg> for Conn {
145145
}
146146

147147
fn start_send(mut self: Pin<&mut Self>, frame: ClientToRelayMsg) -> Result<(), Self::Error> {
148-
if let ClientToRelayMsg::SendPacket { packet, .. } = &frame {
149-
let size = packet.len();
150-
snafu::ensure!(size <= MAX_PACKET_SIZE, ExceedsMaxPacketSizeSnafu { size });
151-
snafu::ensure!(size != 0, EmptyPacketSnafu);
148+
let size = frame.encoded_len();
149+
snafu::ensure!(size <= MAX_PACKET_SIZE, ExceedsMaxPacketSizeSnafu { size });
150+
if let ClientToRelayMsg::Datagrams { datagrams, .. } = &frame {
151+
snafu::ensure!(!datagrams.contents.is_empty(), EmptyPacketSnafu);
152152
}
153153

154154
Pin::new(&mut self.conn)

iroh-relay/src/protos/common.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ pub enum FrameType {
2323
ServerConfirmsAuth = 2,
2424
/// The server frame type for authentication denial
2525
ServerDeniesAuth = 3,
26-
/// 32B dest pub key + content
27-
SendPacket = 4,
28-
/// 32B src pub key + content
29-
RecvPacket = 6,
26+
/// 32B dest pub key + ECN bytes + one datagram's content
27+
ClientToRelayDatagram = 4,
28+
/// 32B dest pub key + ECN byte + segment size u16 + datagrams contents
29+
ClientToRelayDatagramBatch = 5,
30+
/// 32B src pub key + ECN bytes + one datagram's content
31+
RelayToClientDatagram = 6,
32+
/// 32B src pub key + ECN byte + segment size u16 + datagrams contents
33+
RelayToClientDatagramBatch = 7,
3034
/// Sent from server to client to signal that a previous sender is no longer connected.
3135
///
3236
/// That is, if A sent to B, and then if A disconnects, the server sends `FrameType::PeerGone`

iroh-relay/src/protos/handshake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ pub(crate) async fn serverside(
418418
.build()
419419
})?;
420420

421-
if let Ok(()) = client_auth.verify(io) {
421+
if client_auth.verify(io).is_ok() {
422422
trace!(?client_auth.public_key, "authentication succeeded via keying material");
423423
return Ok(SuccessfulAuthentication {
424424
client_key: client_auth.public_key,

0 commit comments

Comments
 (0)