feat(proxy): record tunnel stability metrics

This commit is contained in:
fawney19
2026-05-08 22:03:17 +08:00
parent 9a84a6ff6c
commit a703acd1fe
81 changed files with 7229 additions and 1110 deletions

View File

@@ -33,7 +33,6 @@ pub fn apply_http_client_config(
if let Some(user_agent) = &config.user_agent {
builder = builder.user_agent(user_agent.clone());
}
builder
}
@@ -46,6 +45,14 @@ pub fn build_http_client_with_headers(
default_headers: HeaderMap,
) -> Result<reqwest::Client, reqwest::Error> {
let mut builder = apply_http_client_config(reqwest::Client::builder(), config);
if let Some(proxy_url) = config
.proxy_url
.as_deref()
.map(str::trim)
.filter(|value| !value.is_empty())
{
builder = builder.proxy(reqwest::Proxy::all(proxy_url)?);
}
if !default_headers.is_empty() {
builder = builder.default_headers(default_headers);
}

View File

@@ -9,6 +9,7 @@ pub struct HttpClientConfig {
pub http2_adaptive_window: bool,
pub use_rustls_tls: bool,
pub user_agent: Option<String>,
pub proxy_url: Option<String>,
}
impl Default for HttpClientConfig {
@@ -23,6 +24,7 @@ impl Default for HttpClientConfig {
http2_adaptive_window: false,
use_rustls_tls: true,
user_agent: None,
proxy_url: None,
}
}
}