From 37293b9999b72cc12cc27df5a8a53214f9a3a91b Mon Sep 17 00:00:00 2001 From: ddidderr Date: Fri, 22 May 2026 08:36:21 +0200 Subject: [PATCH] fix(relay): close failed accepted handshakes After a peer is registered, later accepted-handshake failures clean up room and session state. If the welcome was already sent, the joining peer could otherwise keep a live QUIC connection briefly while the relay has removed it from room membership. Close the connection after accepted-handshake cleanup so the peer learns the handshake failed instead of continuing with stale local state. Test Plan: - cargo fmt --check - cargo test -p lanparty-relay - cargo test --workspace - cargo clippy --workspace --all-targets -- -D warnings - git diff --check - git diff --cached --check Refs: MVP lifecycle ordering --- crates/lanparty-relay/src/server.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/lanparty-relay/src/server.rs b/crates/lanparty-relay/src/server.rs index b798d28..d47f643 100644 --- a/crates/lanparty-relay/src/server.rs +++ b/crates/lanparty-relay/src/server.rs @@ -317,6 +317,7 @@ async fn accept_control_handshake( accepted.peer.role() == Role::Client, ) .await?; + close_failed_accepted_handshake(connection); return Err(error); } @@ -332,6 +333,7 @@ async fn accept_control_handshake( accepted.peer.role() == Role::Client, ) .await?; + close_failed_accepted_handshake(connection); return Err(error); } @@ -342,6 +344,10 @@ async fn accept_control_handshake( Ok(Some(accepted)) } +fn close_failed_accepted_handshake(connection: &quinn::Connection) { + connection.close(0_u32.into(), b"relay accepted handshake failed"); +} + const fn accepted_handshake_steps(role: Role) -> &'static [AcceptedHandshakeStep] { match role { Role::Client => CLIENT_HANDSHAKE_STEPS,