From 6114e4ff5554cc98298553690f6bf6fa8cd98ae4 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:28:53 +0800 Subject: [PATCH] Temporary fix for arm64 grpc issues --- v2rayN/v2rayN/App.xaml.cs | 7 +++- v2rayN/v2rayN/Handler/LazyConfig.cs | 6 ++-- v2rayN/v2rayN/Handler/UpdateHandle.cs | 50 ++++++++++++++++++--------- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/v2rayN/v2rayN/App.xaml.cs b/v2rayN/v2rayN/App.xaml.cs index 810f08fc..76a2e041 100644 --- a/v2rayN/v2rayN/App.xaml.cs +++ b/v2rayN/v2rayN/App.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System.Runtime.InteropServices; +using System.Windows; using System.Windows.Threading; using v2rayN.Handler; using v2rayN.Mode; @@ -64,6 +65,10 @@ namespace v2rayN Environment.Exit(0); return; } + if (RuntimeInformation.ProcessArchitecture != Architecture.X86 && RuntimeInformation.ProcessArchitecture != Architecture.X64) + { + _config.guiItem.enableStatistics = false; + } } private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { diff --git a/v2rayN/v2rayN/Handler/LazyConfig.cs b/v2rayN/v2rayN/Handler/LazyConfig.cs index ab9b35c7..e89f3cd4 100644 --- a/v2rayN/v2rayN/Handler/LazyConfig.cs +++ b/v2rayN/v2rayN/Handler/LazyConfig.cs @@ -200,9 +200,9 @@ namespace v2rayN.Handler coreType = ECoreType.v2rayN, coreUrl = Global.NUrl, coreReleaseApiUrl = Global.NUrl.Replace(Global.githubUrl, Global.githubApiUrl), - coreDownloadUrl32 = Global.NUrl + "/download/{0}/v2rayN.zip", + coreDownloadUrl32 = Global.NUrl + "/download/{0}/v2rayN-32.zip", coreDownloadUrl64 = Global.NUrl + "/download/{0}/v2rayN.zip", - coreDownloadUrlArm64= Global.NUrl + "/download/{0}/v2rayN.zip" + coreDownloadUrlArm64 = Global.NUrl + "/download/{0}/v2rayN-arm64.zip" }); coreInfos.Add(new CoreInfo @@ -214,7 +214,7 @@ namespace v2rayN.Handler coreReleaseApiUrl = Global.v2flyCoreUrl.Replace(Global.githubUrl, Global.githubApiUrl), coreDownloadUrl32 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip", coreDownloadUrl64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip", - coreDownloadUrlArm64= Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip", + coreDownloadUrlArm64 = Global.v2flyCoreUrl + "/download/{0}/v2ray-windows-{1}.zip", match = "V2Ray", versionArg = "-version", redirectInfo = true, diff --git a/v2rayN/v2rayN/Handler/UpdateHandle.cs b/v2rayN/v2rayN/Handler/UpdateHandle.cs index d52384c5..2f0ee736 100644 --- a/v2rayN/v2rayN/Handler/UpdateHandle.cs +++ b/v2rayN/v2rayN/Handler/UpdateHandle.cs @@ -443,11 +443,18 @@ namespace v2rayN.Handler { curVersion = "v" + getCoreVersion(type); message = string.Format(ResUI.IsLatestCore, curVersion); - string osBit = Environment.Is64BitProcess ? "64" : "32"; - - if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64) + string osBit = "64"; + switch (RuntimeInformation.ProcessArchitecture) { - osBit = "arm64-v8a"; + case Architecture.Arm64: + osBit = "arm64-v8a"; + break; + case Architecture.X86: + osBit = "32"; + break; + default: + osBit = "64"; + break; } url = string.Format(coreInfo.coreDownloadUrl64, version, osBit); @@ -458,27 +465,36 @@ namespace v2rayN.Handler { curVersion = getCoreVersion(type); message = string.Format(ResUI.IsLatestCore, curVersion); - if (Environment.Is64BitProcess) + switch (RuntimeInformation.ProcessArchitecture) { - url = string.Format(coreInfo.coreDownloadUrl64, version); + case Architecture.Arm64: + url = string.Format(coreInfo.coreDownloadUrlArm64, version); + break; + case Architecture.X86: + url = string.Format(coreInfo.coreDownloadUrl32, version); + break; + default: + url = string.Format(coreInfo.coreDownloadUrl64, version); + break; } - else - { - url = string.Format(coreInfo.coreDownloadUrl32, version); - } - - if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64) - { - url = string.Format(coreInfo.coreDownloadUrlArm64, version); - } - break; } case ECoreType.v2rayN: { curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString(); message = string.Format(ResUI.IsLatestN, curVersion); - url = string.Format(coreInfo.coreDownloadUrl64, version); + switch (RuntimeInformation.ProcessArchitecture) + { + case Architecture.Arm64: + url = string.Format(coreInfo.coreDownloadUrlArm64, version); + break; + case Architecture.X86: + url = string.Format(coreInfo.coreDownloadUrl32, version); + break; + default: + url = string.Format(coreInfo.coreDownloadUrl64, version); + break; + } break; } default: