From 75d86cf88308e38ce335f75585e4af8ed09e0559 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 5 Oct 2024 17:51:31 +0800 Subject: [PATCH] Remove SagerNet clash clash_meta --- v2rayN/ServiceLib/Enums/ECoreType.cs | 6 +-- v2rayN/ServiceLib/Global.cs | 5 +- .../Handler/CoreConfig/CoreConfigHandler.cs | 2 +- v2rayN/ServiceLib/Handler/CoreInfoHandler.cs | 48 +++---------------- v2rayN/ServiceLib/Handler/LazyConfig.cs | 8 ---- .../Handler/Statistics/StatisticsSingbox.cs | 2 +- v2rayN/ServiceLib/Handler/UpdateHandler.cs | 6 --- v2rayN/ServiceLib/Models/Config.cs | 4 +- .../ViewModels/ClashConnectionsViewModel.cs | 2 +- .../ViewModels/ClashProxiesViewModel.cs | 2 +- .../ViewModels/MainWindowViewModel.cs | 2 +- .../v2rayN.Desktop/Views/MainWindow.axaml.cs | 2 - v2rayN/v2rayN/Views/AddServer2Window.xaml.cs | 5 +- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 3 -- 14 files changed, 18 insertions(+), 79 deletions(-) diff --git a/v2rayN/ServiceLib/Enums/ECoreType.cs b/v2rayN/ServiceLib/Enums/ECoreType.cs index cfaffb9f43..35693b0228 100644 --- a/v2rayN/ServiceLib/Enums/ECoreType.cs +++ b/v2rayN/ServiceLib/Enums/ECoreType.cs @@ -4,10 +4,10 @@ public enum ECoreType { v2fly = 1, Xray = 2, - SagerNet = 3, + //SagerNet = 3, v2fly_v5 = 4, - clash = 11, - clash_meta = 12, + //clash = 11, + //clash_meta = 12, mihomo = 13, hysteria = 21, naiveproxy = 22, diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index e2e0a47fe2..56ccaa381f 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -9,10 +9,7 @@ public class Global public const string GithubApiUrl = "https://api.github.com/repos"; public const string V2flyCoreUrl = "https://github.com/v2fly/v2ray-core/releases"; public const string XrayCoreUrl = "https://github.com/XTLS/Xray-core/releases"; - public const string SagerNetCoreUrl = "https://github.com/SagerNet/v2ray-core/releases"; 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"; @@ -166,7 +163,7 @@ public class Global public static readonly List Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" }; public static readonly List Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "splithttp", "h2", "quic", "grpc" }; public static readonly List KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" }; - public static readonly List CoreTypes = new() { "v2fly", "Xray", "sing_box" };//TODO + public static readonly List CoreTypes = new() { "v2fly", "Xray", "sing_box" }; public static readonly List CoreTypes4VLESS = new() { "Xray", "sing_box" }; public static readonly List DomainStrategies = new() { "AsIs", "IPIfNonMatch", "IPOnDemand" }; public static readonly List DomainStrategies4Singbox = new() { "ipv4_only", "ipv6_only", "prefer_ipv4", "prefer_ipv6", "" }; diff --git a/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigHandler.cs b/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigHandler.cs index 21162aad3d..72cea3d7e2 100644 --- a/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigHandler.cs @@ -20,7 +20,7 @@ public static int GenerateClientConfig(ProfileItem node, string? fileName, out s msg = ResUI.InitialConfiguration; if (node.configType == EConfigType.Custom) { - if (node.coreType is ECoreType.clash or ECoreType.clash_meta or ECoreType.mihomo) + if (node.coreType is ECoreType.mihomo) { var configGenClash = new CoreConfigClash(config); return configGenClash.GenerateClientCustomConfig(node, fileName, out msg); diff --git a/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs b/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs index dddaf723f6..0cb4495f0f 100644 --- a/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreInfoHandler.cs @@ -60,18 +60,6 @@ private void InitCoreInfo() redirectInfo = true, }); - _coreInfo.Add(new CoreInfo - { - coreType = ECoreType.SagerNet, - coreExes = new List { "SagerNet", "v2ray" }, - arguments = "run", - coreUrl = Global.SagerNetCoreUrl, - coreReleaseApiUrl = Global.SagerNetCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl), - match = "V2Ray", - versionArg = "version", - redirectInfo = true, - }); - _coreInfo.Add(new CoreInfo { coreType = ECoreType.v2fly_v5, @@ -102,30 +90,6 @@ private void InitCoreInfo() redirectInfo = true, }); - _coreInfo.Add(new CoreInfo - { - coreType = ECoreType.clash, - coreExes = new List { "clash-windows-amd64-v3", "clash-windows-amd64", "clash-windows-386", "clash" }, - arguments = "-f config.json" + PortableMode(), - coreUrl = Global.ClashCoreUrl, - coreReleaseApiUrl = Global.ClashCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl), - match = "v", - versionArg = "-v", - redirectInfo = true, - }); - - _coreInfo.Add(new CoreInfo - { - coreType = ECoreType.clash_meta, - coreExes = new List { "Clash.Meta-windows-amd64-compatible", "Clash.Meta-windows-amd64", "Clash.Meta-windows-386", "Clash.Meta", "clash" }, - arguments = "-f config.json" + PortableMode(), - coreUrl = Global.ClashMetaCoreUrl, - coreReleaseApiUrl = Global.ClashMetaCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl), - match = "v", - versionArg = "-v", - redirectInfo = true, - }); - _coreInfo.Add(new CoreInfo { coreType = ECoreType.mihomo, @@ -133,12 +97,12 @@ private void InitCoreInfo() arguments = "-f config.json" + PortableMode(), coreUrl = Global.MihomoCoreUrl, coreReleaseApiUrl = Global.MihomoCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl), - coreDownloadUrl32 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-windows-386-{0}.zip", - coreDownloadUrl64 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-windows-amd64-compatible-{0}.zip", - coreDownloadUrlArm64 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-windows-arm64-{0}.zip", - coreDownloadUrlLinux32 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-linux-386-{0}.gz", - coreDownloadUrlLinux64 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-linux-amd64-compatible-{0}.gz", - coreDownloadUrlLinuxArm64 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-linux-arm64-{0}.gz", + coreDownloadUrl32 = Global.MihomoCoreUrl + "/download/{0}/mihomo-windows-386-{0}.zip", + coreDownloadUrl64 = Global.MihomoCoreUrl + "/download/{0}/mihomo-windows-amd64-compatible-{0}.zip", + coreDownloadUrlArm64 = Global.MihomoCoreUrl + "/download/{0}/mihomo-windows-arm64-{0}.zip", + coreDownloadUrlLinux32 = Global.MihomoCoreUrl + "/download/{0}/mihomo-linux-386-{0}.gz", + coreDownloadUrlLinux64 = Global.MihomoCoreUrl + "/download/{0}/mihomo-linux-amd64-compatible-{0}.gz", + coreDownloadUrlLinuxArm64 = Global.MihomoCoreUrl + "/download/{0}/mihomo-linux-arm64-{0}.gz", match = "Mihomo", versionArg = "-v", redirectInfo = true, diff --git a/v2rayN/ServiceLib/Handler/LazyConfig.cs b/v2rayN/ServiceLib/Handler/LazyConfig.cs index e54ccdb0e9..afc1f7295f 100644 --- a/v2rayN/ServiceLib/Handler/LazyConfig.cs +++ b/v2rayN/ServiceLib/Handler/LazyConfig.cs @@ -38,14 +38,6 @@ public LazyConfig() SQLiteHelper.Instance.CreateTable(); SQLiteHelper.Instance.CreateTable(); SQLiteHelper.Instance.CreateTable(); - - //TODO - //Prepare to remove the clash - SQLiteHelper.Instance.Execute($"update ProfileItem set coreType = 13 where coreType = 11"); - SQLiteHelper.Instance.Execute($"update ProfileItem set coreType = 13 where coreType = 12"); - //Prepare to remove the SagerNet - SQLiteHelper.Instance.Execute($"update ProfileItem set coreType = 2 where coreType = 3"); - } #region Config diff --git a/v2rayN/ServiceLib/Handler/Statistics/StatisticsSingbox.cs b/v2rayN/ServiceLib/Handler/Statistics/StatisticsSingbox.cs index b26fd6b13f..2052121646 100644 --- a/v2rayN/ServiceLib/Handler/Statistics/StatisticsSingbox.cs +++ b/v2rayN/ServiceLib/Handler/Statistics/StatisticsSingbox.cs @@ -63,7 +63,7 @@ private async void Run() await Task.Delay(1000); try { - if (!(_config.IsRunningCore(ECoreType.clash))) + if (!(_config.IsRunningCore(ECoreType.sing_box))) { continue; } diff --git a/v2rayN/ServiceLib/Handler/UpdateHandler.cs b/v2rayN/ServiceLib/Handler/UpdateHandler.cs index 3fdb7d7f55..f26a1d6e21 100644 --- a/v2rayN/ServiceLib/Handler/UpdateHandler.cs +++ b/v2rayN/ServiceLib/Handler/UpdateHandler.cs @@ -337,14 +337,11 @@ private SemanticVersion GetCoreVersion(ECoreType type) switch (type) { case ECoreType.v2fly: - case ECoreType.SagerNet: case ECoreType.Xray: case ECoreType.v2fly_v5: version = Regex.Match(echo, $"{coreInfo.match} ([0-9.]+) \\(").Groups[1].Value; break; - case ECoreType.clash: - case ECoreType.clash_meta: case ECoreType.mihomo: version = Regex.Match(echo, $"v[0-9.]+").Groups[0].Value; break; @@ -379,7 +376,6 @@ private async Task ParseDownloadUrl(ECoreType type, string gitH switch (type) { case ECoreType.v2fly: - case ECoreType.SagerNet: case ECoreType.Xray: case ECoreType.v2fly_v5: { @@ -388,8 +384,6 @@ private async Task ParseDownloadUrl(ECoreType type, string gitH url = string.Format(GetUrlFromCore(coreInfo), version.ToVersionString("v")); break; } - case ECoreType.clash: - case ECoreType.clash_meta: case ECoreType.mihomo: { curVersion = GetCoreVersion(type); diff --git a/v2rayN/ServiceLib/Models/Config.cs b/v2rayN/ServiceLib/Models/Config.cs index 84de350ac0..53f68ff206 100644 --- a/v2rayN/ServiceLib/Models/Config.cs +++ b/v2rayN/ServiceLib/Models/Config.cs @@ -17,11 +17,11 @@ public class Config public bool IsRunningCore(ECoreType type) { - if (type == ECoreType.Xray && runningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5 or ECoreType.SagerNet) + if (type == ECoreType.Xray && runningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5) { return true; } - if (type == ECoreType.clash && runningCoreType is ECoreType.sing_box or ECoreType.clash or ECoreType.clash_meta or ECoreType.mihomo) + if (type == ECoreType.sing_box && runningCoreType is ECoreType.sing_box or ECoreType.mihomo) { return true; } diff --git a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs index d621e4aa33..caa776dc4e 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs @@ -83,7 +83,7 @@ private void Init() Observable.Interval(TimeSpan.FromSeconds(5)) .Subscribe(x => { - if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.clash))) + if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.sing_box))) { return; } diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index ff8cdd60a1..782ac5dc57 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -439,7 +439,7 @@ public void DelayTestTask() Observable.Interval(TimeSpan.FromSeconds(60)) .Subscribe(x => { - if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.clash))) + if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.sing_box))) { return; } diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 8beebd436a..10e67403b4 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -731,7 +731,7 @@ public void ReloadResult() { ChangeSystemProxyStatusAsync(_config.systemProxyItem.sysProxyType, false); BlReloadEnabled = true; - ShowClashUI = _config.IsRunningCore(ECoreType.clash); + ShowClashUI = _config.IsRunningCore(ECoreType.sing_box); if (ShowClashUI) { Locator.Current.GetService()?.ProxiesReload(); diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index 74ca873941..16a879f0be 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -451,8 +451,6 @@ private void AddHelpMenuItem() var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); foreach (var it in coreInfo .Where(t => t.coreType != ECoreType.v2fly - && t.coreType != ECoreType.clash - && t.coreType != ECoreType.clash_meta && t.coreType != ECoreType.hysteria)) { var item = new MenuItem() diff --git a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs index d9e59fb5d3..3bee918268 100644 --- a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs @@ -17,10 +17,7 @@ public AddServer2Window(ProfileItem profileItem) foreach (ECoreType it in Enum.GetValues(typeof(ECoreType))) { if (it == ECoreType.v2rayN) - continue; - //TODO - if (it is ECoreType.clash or ECoreType.clash_meta or ECoreType.SagerNet) - continue; + continue; cmbCoreType.Items.Add(it.ToString()); } cmbCoreType.Items.Add(string.Empty); diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index 2f7b271aea..ea9d0cfb94 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -493,9 +493,6 @@ private void AddHelpMenuItem() var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); foreach (var it in coreInfo .Where(t => t.coreType != ECoreType.v2fly - && t.coreType != ECoreType.SagerNet - && t.coreType != ECoreType.clash - && t.coreType != ECoreType.clash_meta && t.coreType != ECoreType.hysteria)) { var item = new MenuItem()