Skip to content

Commit

Permalink
up 6.51
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Jul 12, 2024
1 parent 9f4718a commit cfe8fcd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions v2rayN/v2rayN/Handler/DownloadHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,19 @@ public async Task<int> GetRealPingTime(string url, IWebProxy? webProxy, int down
int responseTime = -1;
try
{
Stopwatch timer = Stopwatch.StartNew();

using var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromSeconds(downloadTimeout));
using var client = new HttpClient(new SocketsHttpHandler()
{
Proxy = webProxy,
UseProxy = webProxy != null
});

var timer = Stopwatch.StartNew();

await client.GetAsync(url, cts.Token);

timer.Stop();
responseTime = (int)timer.Elapsed.TotalMilliseconds;
}
catch //(Exception ex)
Expand Down
5 changes: 2 additions & 3 deletions v2rayN/v2rayN/Handler/SpeedtestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,12 @@ private int GetTcpingTime(string url, int port)
ipAddress = ipHostInfo.AddressList[0];
}

Stopwatch timer = new();
timer.Start();
var timer = Stopwatch.StartNew();

IPEndPoint endPoint = new(ipAddress, port);
using Socket clientSocket = new(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

IAsyncResult result = clientSocket.BeginConnect(endPoint, null, null);
var result = clientSocket.BeginConnect(endPoint, null, null);
if (!result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5)))
throw new TimeoutException("connect timeout (5s): " + url);
clientSocket.EndConnect(result);
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN/v2rayN.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
<Copyright>Copyright © 2017-2024 (GPLv3)</Copyright>
<FileVersion>6.50</FileVersion>
<FileVersion>6.51</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Downloader" Version="3.1.2" />
<PackageReference Include="MaterialDesignThemes" Version="5.1.0" />
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.131" />
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.1.0" />
<PackageReference Include="QRCoder.Xaml" Version="1.6.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
<PackageReference Include="TaskScheduler" Version="2.11.0" />
Expand Down

0 comments on commit cfe8fcd

Please sign in to comment.