diff --git a/v2rayN/ProtosLib/ProtosLib.csproj b/v2rayN/ProtosLib/ProtosLib.csproj index 4418da52..0b22dfb8 100644 --- a/v2rayN/ProtosLib/ProtosLib.csproj +++ b/v2rayN/ProtosLib/ProtosLib.csproj @@ -9,7 +9,7 @@ - + all diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index e78ca965..5cf71da7 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -495,7 +495,7 @@ namespace ServiceLib.Common { if (blFull) { - return $"{Global.AppName} - V{GetVersionInfo()} - {File.GetLastWriteTime(GetExePath()):yyyy/MM/dd}"; + return $"{Global.AppName} - V{GetVersionInfo()} - {RuntimeInformation.ProcessArchitecture} - {File.GetLastWriteTime(GetExePath()):yyyy/MM/dd}"; } else { diff --git a/v2rayN/ServiceLib/Handler/AppHandler.cs b/v2rayN/ServiceLib/Handler/AppHandler.cs index e0eae64a..892df4b4 100644 --- a/v2rayN/ServiceLib/Handler/AppHandler.cs +++ b/v2rayN/ServiceLib/Handler/AppHandler.cs @@ -126,18 +126,7 @@ public async Task> ProfileItemIndexes(string subid) { - if (Utils.IsNullOrEmpty(subid)) - { - return (await SQLiteHelper.Instance.TableAsync().ToListAsync()) - .Select(t => t.IndexId) - .ToList(); - } - else - { - return (await SQLiteHelper.Instance.TableAsync().Where(t => t.Subid == subid).ToListAsync()) - .Select(t => t.IndexId) - .ToList(); - } + return (await ProfileItems(subid)).Select(t => t.IndexId).ToList(); } public async Task> ProfileItems(string subid, string filter) diff --git a/v2rayN/ServiceLib/Handler/ClashApiHandler.cs b/v2rayN/ServiceLib/Handler/ClashApiHandler.cs index da0f80c4..dbc98b27 100644 --- a/v2rayN/ServiceLib/Handler/ClashApiHandler.cs +++ b/v2rayN/ServiceLib/Handler/ClashApiHandler.cs @@ -7,7 +7,7 @@ namespace ServiceLib.Handler private static readonly Lazy instance = new(() => new()); public static ClashApiHandler Instance => instance.Value; - private Dictionary? _proxies; + private Dictionary? _proxies; public Dictionary ProfileContent { get; set; } public async Task?> GetClashProxiesAsync(Config config) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index d17b7a7d..1b26e2dc 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -108,7 +108,7 @@ namespace ServiceLib.Handler EnableAutoAdjustMainLvColWidth = true }; config.UiItem.MainColumnItem ??= new(); - + if (Utils.IsNullOrEmpty(config.UiItem.CurrentLanguage)) { if (Thread.CurrentThread.CurrentCulture.Name.Equals("zh-cn", StringComparison.CurrentCultureIgnoreCase)) @@ -380,8 +380,8 @@ namespace ServiceLib.Handler { return 0; } - var count = await SQLiteHelper.Instance.TableAsync().CountAsync(t => t.IndexId == config.IndexId); - if (count > 0) + + if (await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(t => t.IndexId == config.IndexId) != null) { return 0; } @@ -390,7 +390,7 @@ namespace ServiceLib.Handler return await SetDefaultServerIndex(config, lstProfile.FirstOrDefault(t => t.Port > 0)?.IndexId); } - var item = await SQLiteHelper.Instance.TableAsync().Where(t => t.Port > 0).FirstOrDefaultAsync(); + var item = await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(t => t.Port > 0); return await SetDefaultServerIndex(config, item.IndexId); } diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index a260db01..e39b111b 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -42,7 +42,7 @@ namespace ServiceLib.Handler else { ShowMsg(true, $"{node.GetSummary()}"); - CoreStop(); + await CoreStop(); await CoreStart(node); //In tun mode, do a delay check and restart the core @@ -74,19 +74,19 @@ namespace ServiceLib.Handler ShowMsg(false, result.Msg); if (result.Success) { - pid = CoreStartSpeedtest(configPath, coreType); + pid = await CoreStartSpeedtest(configPath, coreType); } return pid; } - public void CoreStop() + public async Task CoreStop() { try { bool hasProc = false; if (_process != null) { - KillProcess(_process); + await KillProcess(_process); _process.Dispose(); _process = null; hasProc = true; @@ -94,7 +94,7 @@ namespace ServiceLib.Handler if (_processPre != null) { - KillProcess(_processPre); + await KillProcess(_processPre); _processPre.Dispose(); _processPre = null; hasProc = true; @@ -117,7 +117,7 @@ namespace ServiceLib.Handler string? path = p.MainModule?.FileName; if (path == Utils.GetExeName(Utils.GetBinPath(vName, it.CoreType.ToString()))) { - KillProcess(p); + await KillProcess(p); } } } @@ -130,12 +130,12 @@ namespace ServiceLib.Handler } } - public void CoreStopPid(int pid) + public async Task CoreStopPid(int pid) { try { var _p = Process.GetProcessById(pid); - KillProcess(_p); + await KillProcess(_p); } catch (Exception ex) { @@ -186,7 +186,7 @@ namespace ServiceLib.Handler var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog; - var proc = RunProcess(node, coreInfo, "", displayLog); + var proc = await RunProcess(node, coreInfo, "", displayLog); if (proc is null) { return; @@ -228,7 +228,7 @@ namespace ServiceLib.Handler if (result.Success) { var coreInfo2 = CoreInfoHandler.Instance.GetCoreInfo(preCoreType); - var proc2 = RunProcess(node, coreInfo2, $" -c {Global.CorePreConfigFileName}", true); + var proc2 = await RunProcess(node, coreInfo2, $" -c {Global.CorePreConfigFileName}", true); if (proc2 is not null) { _processPre = proc2; @@ -238,7 +238,7 @@ namespace ServiceLib.Handler } } - private int CoreStartSpeedtest(string configPath, ECoreType coreType) + private async Task CoreStartSpeedtest(string configPath, ECoreType coreType) { ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); @@ -246,7 +246,7 @@ namespace ServiceLib.Handler try { var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); - var proc = RunProcess(new(), coreInfo, $" -c {Global.CoreSpeedtestConfigFileName}", true); + var proc = await RunProcess(new(), coreInfo, $" -c {Global.CoreSpeedtestConfigFileName}", true); if (proc is null) { return -1; @@ -272,7 +272,7 @@ namespace ServiceLib.Handler #region Process - private Process? RunProcess(ProfileItem node, CoreInfo coreInfo, string configPath, bool displayLog) + private async Task RunProcess(ProfileItem node, CoreInfo coreInfo, string configPath, bool displayLog) { try { @@ -351,7 +351,7 @@ namespace ServiceLib.Handler } } - private void KillProcess(Process? proc) + private async Task KillProcess(Process? proc) { if (proc is null) { diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index 3827c38f..293be335 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -11,8 +11,8 @@ namespace ServiceLib.ViewModels { public class ClashProxiesViewModel : MyReactiveObject { - private Dictionary? _proxies; - private Dictionary? _providers; + private Dictionary? _proxies; + private Dictionary? _providers; private int _delayTimeout = 99999999; private IObservableCollection _proxyGroups = new ObservableCollectionExtended(); diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index d2b38350..d421baea 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -15,7 +15,7 @@ - +