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; 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)) if (string.IsNullOrEmpty(url))
{ {
@@ -64,10 +64,7 @@ namespace v2rayN.Base
} }
try try
{ {
var cts = new CancellationTokenSource(); HttpResponseMessage response = await client.GetAsync(url, token);
cts.CancelAfter(5000);
HttpResponseMessage response = await client.GetAsync(url, cts.Token);
return await response.Content.ReadAsStringAsync(); return await response.Content.ReadAsStringAsync();
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -1273,7 +1273,10 @@ namespace v2rayN.Forms
mainMsgControl.DisplayToolStatus(config); 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 #endregion

View File

@@ -6,6 +6,7 @@ using v2rayN.Mode;
using v2rayN.Base; using v2rayN.Base;
using System.Linq; using System.Linq;
using v2rayN.Tool; using v2rayN.Tool;
using System.Threading.Tasks;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@@ -207,7 +208,27 @@ namespace v2rayN.Handler
{ {
lock (objLock) 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)); 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; return result;
} }
catch (Exception ex) catch (Exception ex)

View File

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