Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5aa307efb | ||
|
|
48928613bf | ||
|
|
52b8f480f6 | ||
|
|
bcda8bd602 | ||
|
|
2a11fe11e8 |
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")]
|
||||
|
||||
Reference in New Issue
Block a user