mirror of https://github.com/telemt/telemt.git
Add 10s timeout to fetch_proxy_config and download_proxy_secret
This commit is contained in:
parent
836eb6f777
commit
39dfc07cbd
|
|
@ -77,10 +77,15 @@ fn parse_proxy_line(line: &str) -> Option<(i32, IpAddr, u16)> {
|
|||
}
|
||||
|
||||
pub async fn fetch_proxy_config(url: &str) -> Result<ProxyConfigData> {
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,13 @@ pub async fn fetch_proxy_secret(cache_path: Option<&str>) -> Result<Vec<u8>> {
|
|||
}
|
||||
|
||||
pub async fn download_proxy_secret() -> Result<Vec<u8>> {
|
||||
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}")))?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue