diff --git a/v2rayN/ServiceLib/Services/DownloadService.cs b/v2rayN/ServiceLib/Services/DownloadService.cs
index db28ea72..f266824b 100644
--- a/v2rayN/ServiceLib/Services/DownloadService.cs
+++ b/v2rayN/ServiceLib/Services/DownloadService.cs
@@ -105,7 +105,7 @@ namespace ServiceLib.Services
{
try
{
- var result1 = await DownloadStringAsync(url, blProxy, userAgent);
+ var result1 = await DownloadStringAsync(url, blProxy, userAgent, 15);
if (Utils.IsNotEmpty(result1))
{
return result1;
@@ -123,7 +123,7 @@ namespace ServiceLib.Services
try
{
- var result2 = await DownloadStringViaDownloader(url, blProxy, userAgent);
+ var result2 = await DownloadStringViaDownloader(url, blProxy, userAgent, 15);
if (Utils.IsNotEmpty(result2))
{
return result2;
@@ -139,26 +139,6 @@ namespace ServiceLib.Services
}
}
- try
- {
- using var wc = new WebClient();
- wc.Proxy = GetWebProxy(blProxy);
- var result3 = await wc.DownloadStringTaskAsync(url);
- if (Utils.IsNotEmpty(result3))
- {
- return result3;
- }
- }
- catch (Exception ex)
- {
- Logging.SaveLog(ex.Message, ex);
- Error?.Invoke(this, new ErrorEventArgs(ex));
- if (ex.InnerException != null)
- {
- Error?.Invoke(this, new ErrorEventArgs(ex.InnerException));
- }
- }
-
return null;
}
@@ -166,7 +146,7 @@ namespace ServiceLib.Services
/// DownloadString
///
///
- public async Task DownloadStringAsync(string url, bool blProxy, string userAgent)
+ private async Task DownloadStringAsync(string url, bool blProxy, string userAgent, int timeout)
{
try
{
@@ -192,7 +172,7 @@ namespace ServiceLib.Services
}
using var cts = new CancellationTokenSource();
- var result = await HttpClientHelper.Instance.GetAsync(client, url, cts.Token).WaitAsync(TimeSpan.FromSeconds(30), cts.Token);
+ var result = await HttpClientHelper.Instance.GetAsync(client, url, cts.Token).WaitAsync(TimeSpan.FromSeconds(timeout), cts.Token);
return result;
}
catch (Exception ex)
@@ -211,7 +191,7 @@ namespace ServiceLib.Services
/// DownloadString
///
///
- public async Task DownloadStringViaDownloader(string url, bool blProxy, string userAgent)
+ private async Task DownloadStringViaDownloader(string url, bool blProxy, string userAgent, int timeout)
{
try
{
@@ -223,7 +203,7 @@ namespace ServiceLib.Services
{
userAgent = Utils.GetVersion(false);
}
- var result = await DownloaderHelper.Instance.DownloadStringAsync(webProxy, url, userAgent, 30);
+ var result = await DownloaderHelper.Instance.DownloadStringAsync(webProxy, url, userAgent, timeout);
return result;
}
catch (Exception ex)
diff --git a/v2rayN/v2rayN.Desktop/Common/AvaUtils.cs b/v2rayN/v2rayN.Desktop/Common/AvaUtils.cs
index 0b9ff319..81b63799 100644
--- a/v2rayN/v2rayN.Desktop/Common/AvaUtils.cs
+++ b/v2rayN/v2rayN.Desktop/Common/AvaUtils.cs
@@ -40,25 +40,7 @@ namespace v2rayN.Desktop.Common
public static WindowIcon GetAppIcon(ESysProxyType sysProxyType)
{
- int index = 1;
- switch (sysProxyType)
- {
- case ESysProxyType.ForcedClear:
- index = 1;
- break;
-
- case ESysProxyType.ForcedChange:
- index = 2;
- break;
-
- case ESysProxyType.Unchanged:
- index = 3;
- break;
-
- case ESysProxyType.Pac:
- index = 4;
- break;
- }
+ var index = (int)sysProxyType + 1;
var uri = new Uri($"avares://{Assembly.GetExecutingAssembly().GetName().Name}/Assets/NotifyIcon{index}.ico");
using var bitmap = new Bitmap(AssetLoader.Open(uri));
return new(bitmap);
diff --git a/v2rayN/v2rayN/Handler/WindowsHandler.cs b/v2rayN/v2rayN/Handler/WindowsHandler.cs
index 2520b47e..3c887d3c 100644
--- a/v2rayN/v2rayN/Handler/WindowsHandler.cs
+++ b/v2rayN/v2rayN/Handler/WindowsHandler.cs
@@ -13,7 +13,7 @@ namespace v2rayN.Handler
{
try
{
- int index = (int)config.systemProxyItem.sysProxyType;
+ var index = (int)config.systemProxyItem.sysProxyType;
//Load from routing setting
var createdIcon = await GetNotifyIcon4Routing(config);
@@ -46,29 +46,11 @@ namespace v2rayN.Handler
public System.Windows.Media.ImageSource GetAppIcon(Config config)
{
- int index = 1;
- switch (config.systemProxyItem.sysProxyType)
- {
- case ESysProxyType.ForcedClear:
- index = 1;
- break;
-
- case ESysProxyType.ForcedChange:
- index = 2;
- break;
-
- case ESysProxyType.Unchanged:
- index = 3;
- break;
-
- case ESysProxyType.Pac:
- index = 4;
- break;
- }
+ var index = (int)config.systemProxyItem.sysProxyType + 1;
return BitmapFrame.Create(new Uri($"pack://application:,,,/Resources/NotifyIcon{index}.ico", UriKind.RelativeOrAbsolute));
}
- private async Task GetNotifyIcon4Routing(Config config)
+ private async Task GetNotifyIcon4Routing(Config config)
{
try
{