feat: 请求日志和 usage 记录中追踪代理节点信息

- 新增 resolve_proxy_info/get_proxy_label 提取脱敏的代理摘要
- StreamContext 增加 proxy_info 字段,流式/非流式全路径写入 metadata
- ProxyNode 缓存补充 name 字段,日志输出代理节点标识
- aether-proxy 连接和转发日志从 debug 提升为 info 级别
- TaskService 代理不可用日志补充 node_id 细节
This commit is contained in:
fawney19
2026-02-08 00:49:43 +08:00
parent 5384ffd403
commit 4a1029961a
9 changed files with 153 additions and 27 deletions

View File

@@ -4,7 +4,7 @@ use std::sync::Arc;
use hyper::body::Incoming;
use hyper::{Request, Response};
use tokio::net::TcpStream;
use tracing::{debug, warn};
use tracing::{debug, info, warn};
use crate::auth;
use crate::config::Config;
@@ -53,7 +53,7 @@ pub async fn handle_connect(
}
};
debug!(target = %target_addr, "CONNECT tunnel establishing");
info!(target = %target_addr, "CONNECT tunnel establishing");
// Connect to target
let target_stream = match TcpStream::connect(target_addr).await {
@@ -74,7 +74,7 @@ pub async fn handle_connect(
match tokio::io::copy_bidirectional(&mut upgraded, &mut target).await {
Ok((from_client, from_target)) => {
debug!(
info!(
from_client,
from_target,
"CONNECT tunnel closed"

View File

@@ -4,7 +4,7 @@ use std::sync::Arc;
use http_body_util::{BodyExt, Full};
use hyper::body::Incoming;
use hyper::{Request, Response};
use tracing::{debug, warn};
use tracing::{debug, info, warn};
use crate::auth;
use crate::config::Config;
@@ -56,7 +56,7 @@ pub async fn handle_plain(
}
};
debug!(target = %target_addr, method = %req.method(), "HTTP proxy forwarding");
info!(target = %target_addr, method = %req.method(), "HTTP proxy forwarding");
// Build outgoing request (strip proxy headers, use relative URI)
let path_and_query = uri
@@ -116,6 +116,7 @@ pub async fn handle_plain(
match sender.send_request(outgoing).await {
Ok(resp) => {
info!(target = %target_addr, status = resp.status().as_u16(), "HTTP proxy response");
// Stream the response body directly — no buffering
let (parts, body) = resp.into_parts();
let body: BoxBody = body

View File

@@ -53,7 +53,7 @@ pub async fn run(
}
};
debug!(peer = %peer_addr, "new connection");
info!(peer = %peer_addr, "new connection");
let config = Arc::clone(&config);
let node_id = Arc::clone(&node_id);