mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
feat(proxy): record tunnel stability metrics
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user