refactor(tunnel): 移除 proxy 连接 idle timeout 机制

idle timeout 在实际使用中容易误断活跃连接,移除该逻辑并简化 reader 循环。
This commit is contained in:
fawney19
2026-04-15 22:10:30 +08:00
parent 704858390d
commit b004551fe5
4 changed files with 3 additions and 23 deletions
@@ -27,7 +27,6 @@ pub enum SendStatus {
#[derive(Debug, Clone, Copy)]
pub struct ConnConfig {
pub ping_interval: Duration,
pub idle_timeout: Duration,
pub outbound_queue_capacity: usize,
}
@@ -490,7 +490,6 @@ mod tests {
ControlPlaneClient::disabled(),
ConnConfig {
ping_interval: Duration::from_secs(15),
idle_timeout: Duration::from_secs(0),
outbound_queue_capacity: 128,
},
128,
@@ -3,7 +3,6 @@
/// Handles the lifecycle of a single aether-proxy connection:
/// accept -> authenticate (headers) -> read loop -> cleanup
use std::sync::Arc;
use std::time::Duration;
use aether_runtime::bounded_queue;
use axum::extract::ws::{Message, WebSocket};
@@ -81,7 +80,7 @@ pub async fn handle_proxy_connection(
let reader_hub = hub.clone();
let reader_conn = conn.clone();
let reader = tokio::spawn(async move {
run_proxy_reader(ws_rx, reader_hub, reader_conn, cfg.idle_timeout).await;
run_proxy_reader(ws_rx, reader_hub, reader_conn).await;
});
let _ = reader.await;
@@ -89,7 +88,7 @@ pub async fn handle_proxy_connection(
conn.request_close();
hub.unregister_proxy(conn_id, &node_id);
drop(conn);
tokio::time::sleep(Duration::from_millis(100)).await;
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
writer.abort();
let _ = writer.await;
}
@@ -98,24 +97,10 @@ async fn run_proxy_reader(
mut ws_rx: futures_util::stream::SplitStream<WebSocket>,
hub: Arc<HubRouter>,
conn: Arc<ProxyConn>,
idle_timeout: Duration,
) {
let idle_enabled = !idle_timeout.is_zero();
let mut oversized_count = 0u32;
loop {
let msg = if idle_enabled {
tokio::select! {
msg = ws_rx.next() => msg,
_ = tokio::time::sleep(idle_timeout) => {
warn!(conn_id = conn.id, node_id = %conn.node_id, "proxy idle timeout");
let _ = conn.send(Message::Binary(protocol::encode_goaway().into()));
conn.request_close();
break;
}
}
} else {
ws_rx.next().await
};
let msg = ws_rx.next().await;
match msg {
Some(Ok(Message::Binary(data))) => {