Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions clash-lib/src/app/api/handlers/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,21 @@ async fn get_proxy_delay(
) -> impl IntoResponse {
let outbound_manager = state.outbound_manager.clone();
let timeout = Duration::from_millis(q.timeout.into());
let n = proxy.name().to_owned();
let name = proxy.name().to_owned();
let mut headers = HeaderMap::new();
headers.insert(header::CONNECTION, "close".parse().unwrap());

let (actual, overall) = if let Some(group) = proxy.try_as_group_handler() {
let latency_test_url = group.get_latency_test_url();
let proxies = group.get_proxies().await;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the current iOS app relies on this behavior somehow, let hold on this and let me double check

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


let proxies = match group.get_active_proxy().await {
Some(v) => vec![v],
None => group.get_proxies().await,
};

let results = outbound_manager
.url_test(
&[vec![proxy], proxies].concat(),
&proxies,
&latency_test_url.unwrap_or(q.url),
timeout,
)
Expand All @@ -154,7 +159,7 @@ async fn get_proxy_delay(
return (
StatusCode::BAD_REQUEST,
headers,
format!("get delay for {n} failed with error: {err}"),
format!("get delay for {name} failed with error: {err}"),
)
.into_response();
}
Expand All @@ -169,7 +174,7 @@ async fn get_proxy_delay(
return (
StatusCode::BAD_REQUEST,
headers,
format!("get delay for {n} failed with error: {err}"),
format!("get delay for {name} failed with error: {err}"),
)
.into_response();
}
Expand Down
Loading