BREAKING CHANGE(ts-api,rustproxy): remove deprecated TypeScript protocol and utility exports while hardening QUIC, HTTP/3, WebSocket, and rate limiter cleanup paths

This commit is contained in:
2026-03-21 22:23:38 +00:00
parent 33fdf42a70
commit fc04a0210b
78 changed files with 331 additions and 10754 deletions

View File

@@ -43,6 +43,7 @@ impl H3ProxyService {
_fallback_route: &RouteConfig,
port: u16,
real_client_addr: Option<SocketAddr>,
parent_cancel: &CancellationToken,
) -> anyhow::Result<()> {
let remote_addr = real_client_addr.unwrap_or_else(|| connection.remote_address());
debug!("HTTP/3 connection from {} on port {}", remote_addr, port);
@@ -55,35 +56,44 @@ impl H3ProxyService {
.map_err(|e| anyhow::anyhow!("H3 connection setup failed: {}", e))?;
loop {
match h3_conn.accept().await {
Ok(Some(resolver)) => {
let (request, stream) = match resolver.resolve_request().await {
Ok(pair) => pair,
let resolver = tokio::select! {
_ = parent_cancel.cancelled() => {
debug!("HTTP/3 connection from {} cancelled by parent", remote_addr);
break;
}
result = h3_conn.accept() => {
match result {
Ok(Some(resolver)) => resolver,
Ok(None) => {
debug!("HTTP/3 connection from {} closed", remote_addr);
break;
}
Err(e) => {
debug!("HTTP/3 request resolve error: {}", e);
continue;
debug!("HTTP/3 accept error from {}: {}", remote_addr, e);
break;
}
};
let http_proxy = Arc::clone(&self.http_proxy);
tokio::spawn(async move {
if let Err(e) = handle_h3_request(
request, stream, port, remote_addr, &http_proxy,
).await {
debug!("HTTP/3 request error from {}: {}", remote_addr, e);
}
});
}
Ok(None) => {
debug!("HTTP/3 connection from {} closed", remote_addr);
break;
}
}
};
let (request, stream) = match resolver.resolve_request().await {
Ok(pair) => pair,
Err(e) => {
debug!("HTTP/3 accept error from {}: {}", remote_addr, e);
break;
debug!("HTTP/3 request resolve error: {}", e);
continue;
}
}
};
let http_proxy = Arc::clone(&self.http_proxy);
let request_cancel = parent_cancel.child_token();
tokio::spawn(async move {
if let Err(e) = handle_h3_request(
request, stream, port, remote_addr, &http_proxy, request_cancel,
).await {
debug!("HTTP/3 request error from {}: {}", remote_addr, e);
}
});
}
Ok(())
@@ -103,13 +113,25 @@ async fn handle_h3_request(
port: u16,
peer_addr: SocketAddr,
http_proxy: &HttpProxyService,
cancel: CancellationToken,
) -> anyhow::Result<()> {
// Stream request body from H3 client via an mpsc channel.
let (body_tx, body_rx) = tokio::sync::mpsc::channel::<Bytes>(4);
// Spawn the H3 body reader task
// Spawn the H3 body reader task with cancellation
let body_cancel = cancel.clone();
let body_reader = tokio::spawn(async move {
while let Ok(Some(mut chunk)) = stream.recv_data().await {
loop {
let chunk = tokio::select! {
_ = body_cancel.cancelled() => break,
result = stream.recv_data() => {
match result {
Ok(Some(chunk)) => chunk,
_ => break,
}
}
};
let mut chunk = chunk;
let data = Bytes::copy_from_slice(chunk.chunk());
chunk.advance(chunk.remaining());
if body_tx.send(data).await.is_err() {
@@ -128,7 +150,6 @@ async fn handle_h3_request(
// Delegate to HttpProxyService — same backend path as TCP/HTTP:
// route matching, ALPN protocol detection, connection pool, H1/H2/H3 auto.
let cancel = CancellationToken::new();
let conn_activity = ConnActivity::new_standalone();
let response = http_proxy.handle_request(req, peer_addr, port, cancel, conn_activity).await
.map_err(|e| anyhow::anyhow!("Backend request failed: {}", e))?;