diff --git a/src/transport/middle_proxy/config_updater.rs b/src/transport/middle_proxy/config_updater.rs index d2bb550..3964ee7 100644 --- a/src/transport/middle_proxy/config_updater.rs +++ b/src/transport/middle_proxy/config_updater.rs @@ -77,10 +77,15 @@ fn parse_proxy_line(line: &str) -> Option<(i32, IpAddr, u16)> { } pub async fn fetch_proxy_config(url: &str) -> Result { - let resp = reqwest::get(url) + let client = reqwest::Client::builder() + .timeout(Duration::from_secs(10)) + .build() + .map_err(|e| crate::error::ProxyError::Proxy(format!("fetch_proxy_config client build failed: {e}")))?; + let resp = client + .get(url) + .send() .await - .map_err(|e| crate::error::ProxyError::Proxy(format!("fetch_proxy_config GET failed: {e}")))? - ; + .map_err(|e| crate::error::ProxyError::Proxy(format!("fetch_proxy_config GET failed: {e}")))?; if let Some(date) = resp.headers().get(reqwest::header::DATE) { if let Ok(date_str) = date.to_str() { diff --git a/src/transport/middle_proxy/secret.rs b/src/transport/middle_proxy/secret.rs index a9e224d..d7824b6 100644 --- a/src/transport/middle_proxy/secret.rs +++ b/src/transport/middle_proxy/secret.rs @@ -54,7 +54,13 @@ pub async fn fetch_proxy_secret(cache_path: Option<&str>) -> Result> { } pub async fn download_proxy_secret() -> Result> { - let resp = reqwest::get("https://core.telegram.org/getProxySecret") + let client = reqwest::Client::builder() + .timeout(Duration::from_secs(10)) + .build() + .map_err(|e| ProxyError::Proxy(format!("Failed to build reqwest client: {e}")))?; + let resp = client + .get("https://core.telegram.org/getProxySecret") + .send() .await .map_err(|e| ProxyError::Proxy(format!("Failed to download proxy-secret: {e}")))?;