Bound WebSocket upgrade handshake duration (#722)

* Bound WebSocket upgrade handshake duration

* Document changed function contracts
This commit is contained in:
jahvari authored and GitHub committed 2026-11-07 12:43:08 +08:00
1 parent 134008e0e9
commit 474fbc7de4
2 files changed
+4 -2

No files matched your search

+2 -1
View File
@@ -419,6 +419,7 @@ async fn handle_connection(
});
}
/// Prepares a TCP or WebSocket relay stream and begins pairing.
async fn make_pair(
stream: TcpStream,
mut addr: SocketAddr,
@@ -452,7 +453,7 @@ async fn make_pair(
}
Ok(response)
};
let ws_stream = tokio_tungstenite::accept_hdr_async(stream, callback).await?;
let ws_stream = timeout(30_000, tokio_tungstenite::accept_hdr_async(stream, callback)).await??;
make_pair_(ws_stream, addr, key, limiter).await;
} else {
make_pair_(FramedStream::from(stream, addr), addr, key, limiter).await;