From 86f3ed29f9caa44ad4248abf126d571e09b08000 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 22 Dec 2023 12:13:36 +0800 Subject: [PATCH] Adjust cores --- v2rayN/v2rayN/Global.cs | 1 + v2rayN/v2rayN/Handler/LazyConfig.cs | 19 ++++++++++++++++--- v2rayN/v2rayN/Mode/ECoreType.cs | 1 + v2rayN/v2rayN/Views/MainWindow.xaml.cs | 10 +++++----- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index 923cdea0..2431f8c7 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -17,6 +17,7 @@ namespace v2rayN public const string NUrl = @"https://github.com/2dust/v2rayN/releases"; public const string ClashCoreUrl = "https://github.com/Dreamacro/clash/releases"; public const string ClashMetaCoreUrl = "https://github.com/MetaCubeX/Clash.Meta/releases"; + public const string MihomoCoreUrl = "https://github.com/MetaCubeX/mihomo/releases"; public const string HysteriaCoreUrl = "https://github.com/apernet/hysteria/releases"; public const string NaiveproxyCoreUrl = "https://github.com/klzgrad/naiveproxy/releases"; public const string TuicCoreUrl = "https://github.com/EAimTY/tuic/releases"; diff --git a/v2rayN/v2rayN/Handler/LazyConfig.cs b/v2rayN/v2rayN/Handler/LazyConfig.cs index 252824e5..36fb0249 100644 --- a/v2rayN/v2rayN/Handler/LazyConfig.cs +++ b/v2rayN/v2rayN/Handler/LazyConfig.cs @@ -1,4 +1,5 @@ -using v2rayN.Base; +using System.Runtime.Intrinsics.X86; +using v2rayN.Base; using v2rayN.Mode; namespace v2rayN.Handler @@ -195,13 +196,13 @@ namespace v2rayN.Handler return coreInfos!.FirstOrDefault(t => t.coreType == coreType); } - public List? GetCoreInfos() + public List GetCoreInfos() { if (coreInfos == null) { InitCoreInfo(); } - return coreInfos; + return coreInfos!; } private void InitCoreInfo() @@ -308,6 +309,18 @@ namespace v2rayN.Handler redirectInfo = true, }); + coreInfos.Add(new CoreInfo + { + coreType = ECoreType.mihomo, + coreExes = new List { $"mihomo-windows-amd64{(Avx2.X64.IsSupported ? "" : "-compatible")}", "mihomo-windows-amd64-compatible", "mihomo-windows-amd64", "mihomo-windows-386", "mihomo", "clash" }, + arguments = "-f config.yaml", + coreUrl = Global.MihomoCoreUrl, + coreReleaseApiUrl = Global.MihomoCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl), + match = "Mihomo", + redirectInfo = true, + }); + + coreInfos.Add(new CoreInfo { coreType = ECoreType.hysteria, diff --git a/v2rayN/v2rayN/Mode/ECoreType.cs b/v2rayN/v2rayN/Mode/ECoreType.cs index 319f3d26..27a88263 100644 --- a/v2rayN/v2rayN/Mode/ECoreType.cs +++ b/v2rayN/v2rayN/Mode/ECoreType.cs @@ -8,6 +8,7 @@ v2fly_v5 = 4, clash = 11, clash_meta = 12, + mihomo = 13, hysteria = 21, naiveproxy = 22, tuic = 23, diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index ffb76232..d6598073 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -541,12 +541,12 @@ namespace v2rayN.Views private void AddHelpMenuItem() { var coreInfos = LazyConfig.Instance.GetCoreInfos(); - foreach (var it in coreInfos) + foreach (var it in coreInfos + .Where(t => t.coreType != ECoreType.v2fly + && t.coreType != ECoreType.clash + && t.coreType != ECoreType.clash_meta + && t.coreType != ECoreType.hysteria)) { - if (it.coreType == ECoreType.v2fly) - { - continue; - } var item = new MenuItem() { Tag = it.coreUrl.Replace(@"/releases", ""),