mirror of
https://github.com/2dust/v2rayN.git
synced 2026-10-13 00:34:58 +03:00
@@ -100,7 +100,7 @@ namespace ServiceLib.Services
|
||||
};
|
||||
HttpClient client = new(webRequestHandler);
|
||||
|
||||
HttpResponseMessage response = await client.GetAsync(url);
|
||||
var response = await client.GetAsync(url);
|
||||
if (response.StatusCode == HttpStatusCode.Redirect && response.Headers.Location is not null)
|
||||
{
|
||||
return response.Headers.Location.ToString();
|
||||
@@ -253,15 +253,12 @@ namespace ServiceLib.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
if (webProxy == null)
|
||||
{
|
||||
webProxy = GetWebProxy(true);
|
||||
}
|
||||
webProxy ??= GetWebProxy(true);
|
||||
|
||||
try
|
||||
{
|
||||
var config = AppHandler.Instance.Config;
|
||||
int responseTime = await GetRealPingTime(config.speedTestItem.speedPingTestUrl, webProxy, 10);
|
||||
var responseTime = await GetRealPingTime(config.speedTestItem.speedPingTestUrl, webProxy, 10);
|
||||
return responseTime;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -279,7 +276,7 @@ namespace ServiceLib.Services
|
||||
|
||||
public async Task<int> GetRealPingTime(string url, IWebProxy? webProxy, int downloadTimeout)
|
||||
{
|
||||
int responseTime = -1;
|
||||
var responseTime = -1;
|
||||
try
|
||||
{
|
||||
using var cts = new CancellationTokenSource();
|
||||
@@ -290,8 +287,8 @@ namespace ServiceLib.Services
|
||||
UseProxy = webProxy != null
|
||||
});
|
||||
|
||||
List<int> oneTime = [];
|
||||
for (int i = 0; i < 2; i++)
|
||||
List<int> oneTime = new();
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
var timer = Stopwatch.StartNew();
|
||||
await client.GetAsync(url, cts.Token);
|
||||
|
||||
Reference in New Issue
Block a user