fix(proxy): improve connection cleanup and route validation handling

This commit is contained in:
2026-03-25 07:22:17 +00:00
parent 34dc0cb9b6
commit 53dee1fffc
12 changed files with 689 additions and 623 deletions

View File

@@ -77,6 +77,13 @@ struct RelaySession {
cancel: CancellationToken,
}
impl Drop for RelaySession {
fn drop(&mut self) {
self.cancel.cancel();
self.return_task.abort();
}
}
/// Create a QUIC endpoint with a PROXY protocol v2 relay layer.
///
/// Instead of giving the external socket to quinn, we:
@@ -634,7 +641,7 @@ async fn forward_quic_stream_to_tcp(
let la_watch = Arc::clone(&last_activity);
let c2b_abort = c2b.abort_handle();
let b2c_abort = b2c.abort_handle();
tokio::spawn(async move {
let watchdog = tokio::spawn(async move {
let check_interval = std::time::Duration::from_secs(5);
let mut last_seen = 0u64;
loop {
@@ -665,6 +672,7 @@ async fn forward_quic_stream_to_tcp(
let bytes_in = c2b.await.unwrap_or(0);
let bytes_out = b2c.await.unwrap_or(0);
watchdog.abort();
Ok((bytes_in, bytes_out))
}