mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-07 03:56:55 +03:00
35 lines
1006 B
TypeScript
35 lines
1006 B
TypeScript
import { getClashApiUrl } from '../../helpers';
|
|
import { createBaseApiRequest, IBaseApiResponse } from '../../api';
|
|
|
|
export async function triggerLatencyGroupTest(
|
|
tag: string,
|
|
timeout: number = 5000,
|
|
url: string = 'https://www.gstatic.com/generate_204',
|
|
): Promise<IBaseApiResponse<void>> {
|
|
return createBaseApiRequest<void>(() =>
|
|
fetch(
|
|
`${getClashApiUrl()}/group/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`,
|
|
{
|
|
method: 'GET',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
export async function triggerLatencyProxyTest(
|
|
tag: string,
|
|
timeout: number = 2000,
|
|
url: string = 'https://www.gstatic.com/generate_204',
|
|
): Promise<IBaseApiResponse<void>> {
|
|
return createBaseApiRequest<void>(() =>
|
|
fetch(
|
|
`${getClashApiUrl()}/proxies/${tag}/delay?url=${encodeURIComponent(url)}&timeout=${timeout}`,
|
|
{
|
|
method: 'GET',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
},
|
|
),
|
|
);
|
|
}
|