Compare commits

...

5 Commits
5.21 ... 5.22

Author SHA1 Message Date
2dust
d5aa307efb Update AssemblyInfo.cs 2022-05-01 16:22:54 +08:00
2dust
48928613bf bug fix 2022-05-01 09:08:16 +08:00
2dust
52b8f480f6 Fix issue when saving gui config 2022-04-30 08:32:42 +08:00
2dust
bcda8bd602 Update subscription timeout is set to 30 seconds 2022-04-30 08:32:26 +08:00
2dust
2a11fe11e8 Fix issue when saving gui config 2022-04-29 10:58:51 +08:00
5 changed files with 34 additions and 9 deletions

View File

@@ -56,7 +56,7 @@ namespace v2rayN.Base
}
return null;
}
public async Task<string> GetAsync(HttpClient client, string url)
public async Task<string> GetAsync(HttpClient client, string url, CancellationToken token)
{
if (string.IsNullOrEmpty(url))
{
@@ -64,10 +64,7 @@ namespace v2rayN.Base
}
try
{
var cts = new CancellationTokenSource();
cts.CancelAfter(5000);
HttpResponseMessage response = await client.GetAsync(url, cts.Token);
HttpResponseMessage response = await client.GetAsync(url, token);
return await response.Content.ReadAsStringAsync();
}
catch (Exception ex)

View File

@@ -1273,7 +1273,10 @@ namespace v2rayN.Forms
mainMsgControl.DisplayToolStatus(config);
notifyMain.Icon = this.Icon = MainFormHandler.Instance.GetNotifyIcon(config, this.Icon);
this.BeginInvoke(new Action(() =>
{
notifyMain.Icon = this.Icon = MainFormHandler.Instance.GetNotifyIcon(config, this.Icon);
}));
}
#endregion

View File

@@ -6,6 +6,7 @@ using v2rayN.Mode;
using v2rayN.Base;
using System.Linq;
using v2rayN.Tool;
using System.Threading.Tasks;
namespace v2rayN.Handler
{
@@ -207,7 +208,27 @@ namespace v2rayN.Handler
{
lock (objLock)
{
Utils.ToJsonFile(config, Utils.GetPath(configRes));
try
{
//save temp file
var temp = $"{configRes}_temp";
if (Utils.ToJsonFile(config, Utils.GetPath(temp)) != 0)
{
return;
}
if (File.Exists(configRes))
{
File.Delete(configRes);
}
//rename
File.Move(temp, configRes);
}
catch (Exception ex)
{
Utils.SaveLog("ToJsonFile", ex);
}
}
}

View File

@@ -156,7 +156,11 @@ namespace v2rayN.Handler
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Utils.Base64Encode(uri.UserInfo));
}
var result = await HttpClientHelper.GetInstance().GetAsync(client, url);
var cts = new CancellationTokenSource();
cts.CancelAfter(1000 * 30);
var result = await HttpClientHelper.GetInstance().GetAsync(client, url, cts.Token);
return result;
}
catch (Exception ex)

View File

@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
// 方法是按如下所示使用“*”:
//[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("5.21")]
[assembly: AssemblyFileVersion("5.22")]