From e3589341144337b26cda26ad9a5131c3c6fc6cd9 Mon Sep 17 00:00:00 2001 From: DHR60 <192860629+DHR60@users.noreply.github.com> Date: Wed, 18 Nov 2026 02:51:52 +0000 Subject: [PATCH] Fix update (#10615) * Fix update * Clean --- v2rayN/ServiceLib/Resx/ResUI.Designer.cs | 178 +++++++++--------- v2rayN/ServiceLib/Services/DownloadService.cs | 11 +- v2rayN/ServiceLib/Services/UpdateService.cs | 2 +- 3 files changed, 97 insertions(+), 94 deletions(-) diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index a57dd707..28e71a68 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -995,7 +995,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("menuClose", resourceCulture); } } - + /// /// 查找类似 Close Connection 的本地化字符串。 /// @@ -1040,7 +1040,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("menuCurrentlyFrozenColumns", resourceCulture); } } - + /// /// 查找类似 Latency Test 的本地化字符串。 /// @@ -1193,7 +1193,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("menuFreezeToThisColumn", resourceCulture); } } - + /// /// 查找类似 Full Config Template Setting 的本地化字符串。 /// @@ -1247,7 +1247,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("menuHideThisColumn", resourceCulture); } } - + /// /// 查找类似 Import Rules From Clipboard 的本地化字符串。 /// @@ -1832,7 +1832,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("menuShowColumns", resourceCulture); } } - + /// /// 查找类似 Show or hide the main window 的本地化字符串。 /// @@ -2030,7 +2030,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("menuUnfreezeAllColumns", resourceCulture); } } - + /// /// 查找类似 {0} Website 的本地化字符串。 /// @@ -4949,7 +4949,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("TbSettingsTunAutoRoute", resourceCulture); } } - + /// /// 查找类似 DNS mode 的本地化字符串。 /// @@ -5418,6 +5418,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 XDRIVE service 的本地化字符串。 + /// + public static string TransportHeaderType6 { + get { + return ResourceManager.GetString("TransportHeaderType6", resourceCulture); + } + } + /// /// 查找类似 *ws/http upgrade/xhttp path 的本地化字符串。 /// @@ -5463,6 +5472,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 XDRIVE remote folder 的本地化字符串。 + /// + public static string TransportPathTip6 { + get { + return ResourceManager.GetString("TransportPathTip6", resourceCulture); + } + } + /// /// 查找类似 *http host separated by commas (,) 的本地化字符串。 /// @@ -5516,79 +5534,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("UpgradeAppNotExistTip", resourceCulture); } } - - /// - /// 查找类似 Preset Provider 的本地化字符串。 - /// - public static string XdriveProvider { - get { - return ResourceManager.GetString("XdriveProvider", resourceCulture); - } - } - - /// - /// 查找类似 XDRIVE service 的本地化字符串。 - /// - public static string XdriveService { - get { - return ResourceManager.GetString("XdriveService", resourceCulture); - } - } - - /// - /// 查找类似 Remote folder 的本地化字符串。 - /// - public static string XdriveRemoteFolder { - get { - return ResourceManager.GetString("XdriveRemoteFolder", resourceCulture); - } - } - - /// - /// 查找类似 Secrets (comma separated) 的本地化字符串。 - /// - public static string XdriveSecrets { - get { - return ResourceManager.GetString("XdriveSecrets", resourceCulture); - } - } - - /// - /// 查找类似 S3 Endpoint 的本地化字符串。 - /// - public static string XdriveS3Endpoint { - get { - return ResourceManager.GetString("XdriveS3Endpoint", resourceCulture); - } - } - - /// - /// 查找类似 S3 Region 的本地化字符串。 - /// - public static string XdriveS3Region { - get { - return ResourceManager.GetString("XdriveS3Region", resourceCulture); - } - } - - /// - /// 查找类似 S3 Bucket 的本地化字符串。 - /// - public static string XdriveS3Bucket { - get { - return ResourceManager.GetString("XdriveS3Bucket", resourceCulture); - } - } - - /// - /// 查找类似 S3 Force Path Style 的本地化字符串。 - /// - public static string XdriveS3PathStyle { - get { - return ResourceManager.GetString("XdriveS3PathStyle", resourceCulture); - } - } - + /// /// 查找类似 XDRIVE Extra 的本地化字符串。 /// @@ -5597,7 +5543,7 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("XdriveExtra", resourceCulture); } } - + /// /// 查找类似 Raw JSON, format: { XdriveObject } 的本地化字符串。 /// @@ -5606,22 +5552,76 @@ namespace ServiceLib.Resx { return ResourceManager.GetString("XdriveExtraTip", resourceCulture); } } - + /// - /// 查找类似 XDRIVE service 的本地化字符串。 + /// 查找类似 Preset Provider 的本地化字符串。 /// - public static string TransportHeaderType6 { + public static string XdriveProvider { get { - return ResourceManager.GetString("TransportHeaderType6", resourceCulture); + return ResourceManager.GetString("XdriveProvider", resourceCulture); } } - + /// - /// 查找类似 XDRIVE remote folder 的本地化字符串。 + /// 查找类似 Remote folder (remoteFolder) 的本地化字符串。 /// - public static string TransportPathTip6 { + public static string XdriveRemoteFolder { get { - return ResourceManager.GetString("TransportPathTip6", resourceCulture); + return ResourceManager.GetString("XdriveRemoteFolder", resourceCulture); + } + } + + /// + /// 查找类似 S3 Bucket 的本地化字符串。 + /// + public static string XdriveS3Bucket { + get { + return ResourceManager.GetString("XdriveS3Bucket", resourceCulture); + } + } + + /// + /// 查找类似 S3 Endpoint 的本地化字符串。 + /// + public static string XdriveS3Endpoint { + get { + return ResourceManager.GetString("XdriveS3Endpoint", resourceCulture); + } + } + + /// + /// 查找类似 S3 Force Path Style 的本地化字符串。 + /// + public static string XdriveS3PathStyle { + get { + return ResourceManager.GetString("XdriveS3PathStyle", resourceCulture); + } + } + + /// + /// 查找类似 S3 Region 的本地化字符串。 + /// + public static string XdriveS3Region { + get { + return ResourceManager.GetString("XdriveS3Region", resourceCulture); + } + } + + /// + /// 查找类似 Secrets (AK,SK / OAuth) 的本地化字符串。 + /// + public static string XdriveSecrets { + get { + return ResourceManager.GetString("XdriveSecrets", resourceCulture); + } + } + + /// + /// 查找类似 Storage service (service) 的本地化字符串。 + /// + public static string XdriveService { + get { + return ResourceManager.GetString("XdriveService", resourceCulture); } } } diff --git a/v2rayN/ServiceLib/Services/DownloadService.cs b/v2rayN/ServiceLib/Services/DownloadService.cs index 5f5e3114..a657512e 100644 --- a/v2rayN/ServiceLib/Services/DownloadService.cs +++ b/v2rayN/ServiceLib/Services/DownloadService.cs @@ -204,15 +204,18 @@ public class DownloadService : IDisposable /// /// Gets redirect target URL without following redirects automatically. /// - public async Task UrlRedirectAsync(string url, CancellationToken cancellationToken = default) + public async Task GetFinalUrlAsync(string url, CancellationToken cancellationToken = default) { using var client = new HttpClient(GetHandler(), false); + using var response = await client.GetAsync(url, cancellationToken); - var response = await client.GetAsync(url, cancellationToken); - if (response.StatusCode == HttpStatusCode.Redirect && response.Headers.Location is not null) + var originalUri = new Uri(url); + var finalUri = response.RequestMessage?.RequestUri; + if (finalUri is not null && !Uri.Equals(originalUri, finalUri)) { - return response.Headers.Location.ToString(); + return finalUri.ToString(); } + Error?.Invoke(this, new ErrorEventArgs(new Exception("StatusCode error: " + response.StatusCode))); Logging.SaveLog("StatusCode error: " + url); return null; diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index 07fa7cbc..737aa271 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -206,7 +206,7 @@ public partial class UpdateService(DownloadService downloadService, Config confi else { var url = Path.Combine(coreInfo.Url, "latest"); - var lastUrl = await downloadService.UrlRedirectAsync(url, cancellationToken); + var lastUrl = await downloadService.GetFinalUrlAsync(url, cancellationToken); if (lastUrl == null) { return new UpdateResult(false, "");