diff --git a/v2rayN/AmazTool/UpgradeApp.cs b/v2rayN/AmazTool/UpgradeApp.cs index 03e234a0b0e..ead7e57e3e7 100644 --- a/v2rayN/AmazTool/UpgradeApp.cs +++ b/v2rayN/AmazTool/UpgradeApp.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.IO.Compression; using System.Text; @@ -59,7 +59,8 @@ public static void Upgrade(string fileName) Console.WriteLine(entry.FullName); var lst = entry.FullName.Split(splitKey); - if (lst.Length == 1) continue; + if (lst.Length == 1) + continue; var fullName = string.Join(splitKey, lst[1..lst.Length]); if (string.Equals(Utils.GetExePath(), Utils.GetPath(fullName), StringComparison.OrdinalIgnoreCase)) @@ -101,4 +102,4 @@ public static void Upgrade(string fileName) Utils.StartV2RayN(); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Common/DownloaderHelper.cs b/v2rayN/ServiceLib/Common/DownloaderHelper.cs index 2aaa2371d65..a7870041cf0 100644 --- a/v2rayN/ServiceLib/Common/DownloaderHelper.cs +++ b/v2rayN/ServiceLib/Common/DownloaderHelper.cs @@ -1,5 +1,5 @@ -using Downloader; using System.Net; +using Downloader; namespace ServiceLib.Common { @@ -181,4 +181,4 @@ public async Task DownloadFileAsync(IWebProxy? webProxy, string url, string file downloadOpt = null; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Common/HttpClientHelper.cs b/v2rayN/ServiceLib/Common/HttpClientHelper.cs index 2959875b9b7..9c8082a02d5 100644 --- a/v2rayN/ServiceLib/Common/HttpClientHelper.cs +++ b/v2rayN/ServiceLib/Common/HttpClientHelper.cs @@ -38,13 +38,15 @@ public class HttpClientHelper public async Task GetAsync(string url) { - if (Utils.IsNullOrEmpty(url)) return null; + if (Utils.IsNullOrEmpty(url)) + return null; return await httpClient.GetStringAsync(url); } public async Task GetAsync(HttpClient client, string url, CancellationToken token = default) { - if (Utils.IsNullOrEmpty(url)) return null; + if (Utils.IsNullOrEmpty(url)) + return null; return await client.GetStringAsync(url, token); } @@ -75,11 +77,13 @@ public static async Task DownloadFileAsync(HttpClient client, string url, string { ArgumentNullException.ThrowIfNull(url); ArgumentNullException.ThrowIfNull(fileName); - if (File.Exists(fileName)) File.Delete(fileName); + if (File.Exists(fileName)) + File.Delete(fileName); using var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token); - if (!response.IsSuccessStatusCode) throw new Exception(response.StatusCode.ToString()); + if (!response.IsSuccessStatusCode) + throw new Exception(response.StatusCode.ToString()); var total = response.Content.Headers.ContentLength ?? -1L; var canReportProgress = total != -1 && progress != null; @@ -97,7 +101,8 @@ public static async Task DownloadFileAsync(HttpClient client, string url, string var read = await stream.ReadAsync(buffer, token); totalRead += read; - if (read == 0) break; + if (read == 0) + break; await file.WriteAsync(buffer.AsMemory(0, read), token); if (canReportProgress) @@ -183,4 +188,4 @@ public async Task DownloadDataAsync4Speed(HttpClient client, string url, IProgre } while (isMoreToRead); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Common/Job.cs b/v2rayN/ServiceLib/Common/Job.cs index 4acf752050c..5b0276f3770 100644 --- a/v2rayN/ServiceLib/Common/Job.cs +++ b/v2rayN/ServiceLib/Common/Job.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.Runtime.InteropServices; namespace ServiceLib.Common @@ -75,7 +75,8 @@ public void Dispose() private void Dispose(bool disposing) { - if (disposed) return; + if (disposed) + return; disposed = true; if (disposing) @@ -173,4 +174,4 @@ public enum JobObjectInfoType } #endregion Helper classes -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Common/Logging.cs b/v2rayN/ServiceLib/Common/Logging.cs index 7031260fa26..16c9228ae13 100644 --- a/v2rayN/ServiceLib/Common/Logging.cs +++ b/v2rayN/ServiceLib/Common/Logging.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NLog.Config; using NLog.Targets; @@ -27,14 +27,16 @@ public static void LoggingEnabled(bool enable) public static void SaveLog(string strContent) { - if (!LogManager.IsLoggingEnabled()) return; + if (!LogManager.IsLoggingEnabled()) + return; LogManager.GetLogger("Log1").Info(strContent); } public static void SaveLog(string strTitle, Exception ex) { - if (!LogManager.IsLoggingEnabled()) return; + if (!LogManager.IsLoggingEnabled()) + return; var logger = LogManager.GetLogger("Log2"); logger.Debug($"{strTitle},{ex.Message}"); @@ -45,4 +47,4 @@ public static void SaveLog(string strTitle, Exception ex) } } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Common/ProcUtils.cs b/v2rayN/ServiceLib/Common/ProcUtils.cs index b58ca41cc43..0013b317b3e 100644 --- a/v2rayN/ServiceLib/Common/ProcUtils.cs +++ b/v2rayN/ServiceLib/Common/ProcUtils.cs @@ -19,8 +19,10 @@ public static void ProcessStart(string? fileName, string arguments = "") } try { - if (fileName.Contains(' ')) fileName = fileName.AppendQuotes(); - if (arguments.Contains(' ')) arguments = arguments.AppendQuotes(); + if (fileName.Contains(' ')) + fileName = fileName.AppendQuotes(); + if (arguments.Contains(' ')) + arguments = arguments.AppendQuotes(); Process process = new() { @@ -83,10 +85,18 @@ public static async Task ProcessKill(Process? proc, bool review) GetProcessKeyInfo(proc, review, out var procId, out var fileName, out var processName); - try { proc?.Kill(true); } catch (Exception ex) { Logging.SaveLog(_tag, ex); } - try { proc?.Kill(); } catch (Exception ex) { Logging.SaveLog(_tag, ex); } - try { proc?.Close(); } catch (Exception ex) { Logging.SaveLog(_tag, ex); } - try { proc?.Dispose(); } catch (Exception ex) { Logging.SaveLog(_tag, ex); } + try + { proc?.Kill(true); } + catch (Exception ex) { Logging.SaveLog(_tag, ex); } + try + { proc?.Kill(); } + catch (Exception ex) { Logging.SaveLog(_tag, ex); } + try + { proc?.Close(); } + catch (Exception ex) { Logging.SaveLog(_tag, ex); } + try + { proc?.Dispose(); } + catch (Exception ex) { Logging.SaveLog(_tag, ex); } await Task.Delay(300); await ProcessKillByKeyInfo(review, procId, fileName, processName); @@ -97,7 +107,8 @@ private static void GetProcessKeyInfo(Process? proc, bool review, out int? procI procId = null; fileName = null; processName = null; - if (!review) return; + if (!review) + return; try { procId = proc?.Id; @@ -136,4 +147,4 @@ private static async Task ProcessKillByKeyInfo(bool review, int? procId, string? } } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Common/SqliteHelper.cs b/v2rayN/ServiceLib/Common/SqliteHelper.cs index 3a8946bf959..10a7793b22b 100644 --- a/v2rayN/ServiceLib/Common/SqliteHelper.cs +++ b/v2rayN/ServiceLib/Common/SqliteHelper.cs @@ -1,5 +1,5 @@ -using SQLite; using System.Collections; +using SQLite; namespace ServiceLib.Common { @@ -88,4 +88,4 @@ await Task.Factory.StartNew(() => }); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Common/StringEx.cs b/v2rayN/ServiceLib/Common/StringEx.cs index c0d0a8ccfb9..ab21016aba0 100644 --- a/v2rayN/ServiceLib/Common/StringEx.cs +++ b/v2rayN/ServiceLib/Common/StringEx.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; namespace ServiceLib.Common { @@ -21,7 +21,8 @@ public static bool IsNotEmpty([NotNullWhen(false)] this string? value) public static bool BeginWithAny(this string s, IEnumerable chars) { - if (s.IsNullOrEmpty()) return false; + if (s.IsNullOrEmpty()) + return false; return chars.Contains(s.First()); } @@ -34,7 +35,8 @@ public static IEnumerable NonWhiteSpaceLines(this TextReader reader) { while (reader.ReadLine() is { } line) { - if (line.IsWhiteSpace()) continue; + if (line.IsWhiteSpace()) + continue; yield return line; } } @@ -69,4 +71,4 @@ public static string AppendQuotes(this string value) return string.IsNullOrEmpty(value) ? string.Empty : $"\"{value}\""; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index f158097bcea..b318f89d0c1 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -1,5 +1,3 @@ -using CliWrap; -using CliWrap.Buffered; using System.Collections.Specialized; using System.Diagnostics; using System.Net; @@ -10,6 +8,8 @@ using System.Security.Cryptography; using System.Security.Principal; using System.Text; +using CliWrap; +using CliWrap.Buffered; namespace ServiceLib.Common { @@ -176,7 +176,8 @@ public static string Base64Decode(string? plainText) { try { - if (plainText.IsNullOrEmpty()) return ""; + if (plainText.IsNullOrEmpty()) + return ""; plainText = plainText.Trim() .Replace(Environment.NewLine, "") .Replace("\n", "") @@ -372,7 +373,8 @@ public static string GetPunycode(string url) public static bool IsBase64String(string? plainText) { - if (plainText.IsNullOrEmpty()) return false; + if (plainText.IsNullOrEmpty()) + return false; var buffer = new Span(new byte[plainText.Length]); return Convert.TryFromBase64String(plainText, buffer, out var _); } @@ -462,9 +464,12 @@ public static bool IsPrivateNetwork(string ip) if (IPAddress.TryParse(ip, out var address)) { var ipBytes = address.GetAddressBytes(); - if (ipBytes[0] == 10) return true; - if (ipBytes[0] == 172 && ipBytes[1] >= 16 && ipBytes[1] <= 31) return true; - if (ipBytes[0] == 192 && ipBytes[1] == 168) return true; + if (ipBytes[0] == 10) + return true; + if (ipBytes[0] == 172 && ipBytes[1] >= 16 && ipBytes[1] <= 31) + return true; + if (ipBytes[0] == 192 && ipBytes[1] == 168) + return true; } return false; @@ -604,9 +609,11 @@ public static Dictionary GetSystemHosts() foreach (var host in hostsList) { - if (host.StartsWith("#")) continue; + if (host.StartsWith("#")) + continue; var hostItem = host.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); - if (hostItem.Length != 2) continue; + if (hostItem.Length != 2) + continue; systemHosts.Add(hostItem.Last(), hostItem.First()); } } @@ -875,8 +882,10 @@ public static bool IsAdministrator() public static async Task SetLinuxChmod(string? fileName) { - if (fileName.IsNullOrEmpty()) return null; - if (fileName.Contains(' ')) fileName = fileName.AppendQuotes(); + if (fileName.IsNullOrEmpty()) + return null; + if (fileName.Contains(' ')) + fileName = fileName.AppendQuotes(); //File.SetUnixFileMode(fileName, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); var arg = new List() { "-c", $"chmod +x {fileName}" }; return await GetCliWrapOutput("/bin/bash", arg); @@ -904,4 +913,4 @@ public static bool IsAdministrator() #endregion Platform } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Common/WindowsUtils.cs b/v2rayN/ServiceLib/Common/WindowsUtils.cs index 80d2035733d..77877d602d1 100644 --- a/v2rayN/ServiceLib/Common/WindowsUtils.cs +++ b/v2rayN/ServiceLib/Common/WindowsUtils.cs @@ -1,4 +1,3 @@ -using System.Diagnostics; using System.Security.Cryptography; using System.Text; using Microsoft.Win32; @@ -56,21 +55,20 @@ public static void RegWriteValue(string path, string name, object value) public static async Task RemoveTunDevice() { - try - { - var sum = MD5.HashData(Encoding.UTF8.GetBytes("wintunsingbox_tun")); - var guid = new Guid(sum); - var pnpUtilPath = @"C:\Windows\System32\pnputil.exe"; - var arg = $$""" /remove-device "SWD\Wintun\{{{guid}}}" """; + try + { + var sum = MD5.HashData(Encoding.UTF8.GetBytes("wintunsingbox_tun")); + var guid = new Guid(sum); + var pnpUtilPath = @"C:\Windows\System32\pnputil.exe"; + var arg = $$""" /remove-device "SWD\Wintun\{{{guid}}}" """; - // Try to remove the device - await Utils.GetCliWrapOutput(pnpUtilPath, arg); - - } - catch (Exception ex) - { - Logging.SaveLog(_tag, ex); - } - } - } + // Try to remove the device + await Utils.GetCliWrapOutput(pnpUtilPath, arg); + } + catch (Exception ex) + { + Logging.SaveLog(_tag, ex); + } + } + } } diff --git a/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs b/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs index 2858ac232aa..2e3846b2a65 100644 --- a/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs +++ b/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs @@ -1,4 +1,3 @@ -using System.Diagnostics; using System.Security.Principal; using System.Text.RegularExpressions; @@ -30,12 +29,12 @@ public static async Task UpdateTask(Config config) } else if (Utils.IsOSX()) { - await ClearTaskOSX(); + await ClearTaskOSX(); - if (config.GuiItem.AutoRun) - { - await SetTaskOSX(); - } + if (config.GuiItem.AutoRun) + { + await SetTaskOSX(); + } } return true; @@ -172,46 +171,46 @@ private static string GetHomePathLinux() private static async Task ClearTaskOSX() { - try - { - var launchAgentPath = GetLaunchAgentPathMacOS(); - if (File.Exists(launchAgentPath)) - { - var args = new[] { "-c", $"launchctl unload -w \"{launchAgentPath}\"" }; - await Utils.GetCliWrapOutput("/bin/bash", args); - - File.Delete(launchAgentPath); - } - } - catch (Exception ex) - { - Logging.SaveLog(_tag, ex); - } + try + { + var launchAgentPath = GetLaunchAgentPathMacOS(); + if (File.Exists(launchAgentPath)) + { + var args = new[] { "-c", $"launchctl unload -w \"{launchAgentPath}\"" }; + await Utils.GetCliWrapOutput("/bin/bash", args); + + File.Delete(launchAgentPath); + } + } + catch (Exception ex) + { + Logging.SaveLog(_tag, ex); + } } private static async Task SetTaskOSX() { - try - { - var plistContent = GenerateLaunchAgentPlist(); - var launchAgentPath = GetLaunchAgentPathMacOS(); - await File.WriteAllTextAsync(launchAgentPath, plistContent); - - var args = new[] { "-c", $"launchctl load -w \"{launchAgentPath}\"" }; - await Utils.GetCliWrapOutput("/bin/bash", args); - } - catch (Exception ex) - { - Logging.SaveLog(_tag, ex); - } + try + { + var plistContent = GenerateLaunchAgentPlist(); + var launchAgentPath = GetLaunchAgentPathMacOS(); + await File.WriteAllTextAsync(launchAgentPath, plistContent); + + var args = new[] { "-c", $"launchctl load -w \"{launchAgentPath}\"" }; + await Utils.GetCliWrapOutput("/bin/bash", args); + } + catch (Exception ex) + { + Logging.SaveLog(_tag, ex); + } } private static string GetLaunchAgentPathMacOS() { - var homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - var launchAgentPath = Path.Combine(homePath, "Library", "LaunchAgents", $"{Global.AppName}-LaunchAgent.plist"); - Directory.CreateDirectory(Path.GetDirectoryName(launchAgentPath)); - return launchAgentPath; + var homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + var launchAgentPath = Path.Combine(homePath, "Library", "LaunchAgents", $"{Global.AppName}-LaunchAgent.plist"); + Directory.CreateDirectory(Path.GetDirectoryName(launchAgentPath)); + return launchAgentPath; } private static string GenerateLaunchAgentPlist() diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 5142f37ce38..f57329822bd 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -873,7 +873,8 @@ public static async Task> DedupServerList(Config config, string List lstKeep = new(); List lstRemove = new(); - if (!config.GuiItem.KeepOlderDedupl) lstProfile.Reverse(); + if (!config.GuiItem.KeepOlderDedupl) + lstProfile.Reverse(); foreach (ProfileItem item in lstProfile) { @@ -1363,7 +1364,8 @@ public static async Task AddSubItem(Config config, string url) }; var uri = Utils.TryUri(url); - if (uri == null) return -1; + if (uri == null) + return -1; //Do not allow http protocol if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost)) { @@ -1885,4 +1887,4 @@ public static async Task ApplyRegionalPreset(Config config, EPresetType ty #endregion Regional Presets } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index 399b4a9fbdd..1270d8caacd 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -84,13 +84,13 @@ public async Task LoadCore(ProfileItem? node) await CoreStop(); await Task.Delay(100); - if (Utils.IsWindows() && _config.TunModeItem.EnableTun) - { - await Task.Delay(100); - await WindowsUtils.RemoveTunDevice(); - } + if (Utils.IsWindows() && _config.TunModeItem.EnableTun) + { + await Task.Delay(100); + await WindowsUtils.RemoveTunDevice(); + } - await CoreStart(node); + await CoreStart(node); await CoreStartPreService(node); if (_process != null) { @@ -246,12 +246,14 @@ private bool IsNeedSudo(ECoreType eCoreType) { proc.OutputDataReceived += (sender, e) => { - if (Utils.IsNullOrEmpty(e.Data)) return; + if (Utils.IsNullOrEmpty(e.Data)) + return; UpdateFunc(false, e.Data + Environment.NewLine); }; proc.ErrorDataReceived += (sender, e) => { - if (Utils.IsNullOrEmpty(e.Data)) return; + if (Utils.IsNullOrEmpty(e.Data)) + return; UpdateFunc(false, e.Data + Environment.NewLine); }; } @@ -265,7 +267,8 @@ private bool IsNeedSudo(ECoreType eCoreType) await Task.Delay(10); await proc.StandardInput.WriteLineAsync(pwd); } - if (isNeedSudo) _linuxSudoPid = proc.Id; + if (isNeedSudo) + _linuxSudoPid = proc.Id; if (displayLog) { diff --git a/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs index 7afa005a0bf..276cd44d16b 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs @@ -1,4 +1,4 @@ -using System.Collections.Specialized; +using System.Collections.Specialized; namespace ServiceLib.Handler.Fmt { @@ -214,7 +214,8 @@ protected static bool Contains(string str, params string[] s) { foreach (var item in s) { - if (str.Contains(item, StringComparison.OrdinalIgnoreCase)) return true; + if (str.Contains(item, StringComparison.OrdinalIgnoreCase)) + return true; } return false; } @@ -236,4 +237,4 @@ protected static string ToUri(EConfigType eConfigType, string address, object po return $"{Global.ProtocolShares[eConfigType]}{url}{query}{remark}"; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs b/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs index 7f51120c64a..b57abe0a5d1 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs @@ -1,4 +1,4 @@ -namespace ServiceLib.Handler.Fmt +namespace ServiceLib.Handler.Fmt { public class Hysteria2Fmt : BaseFmt { @@ -11,7 +11,8 @@ public class Hysteria2Fmt : BaseFmt }; var url = Utils.TryUri(str); - if (url == null) return null; + if (url == null) + return null; item.Address = url.IdnHost; item.Port = url.Port; @@ -28,7 +29,8 @@ public class Hysteria2Fmt : BaseFmt public static string? ToUri(ProfileItem? item) { - if (item == null) return null; + if (item == null) + return null; string url = string.Empty; string remark = string.Empty; @@ -91,4 +93,4 @@ public class Hysteria2Fmt : BaseFmt return null; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs index f9028c444c6..a9ebac335b5 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs @@ -1,4 +1,4 @@ -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace ServiceLib.Handler.Fmt { @@ -26,7 +26,8 @@ public class ShadowsocksFmt : BaseFmt public static string? ToUri(ProfileItem? item) { - if (item == null) return null; + if (item == null) + return null; string url = string.Empty; string remark = string.Empty; @@ -82,7 +83,8 @@ public class ShadowsocksFmt : BaseFmt private static ProfileItem? ResolveSip002(string result) { var parsedUrl = Utils.TryUri(result); - if (parsedUrl == null) return null; + if (parsedUrl == null) + return null; ProfileItem item = new() { @@ -169,4 +171,4 @@ public class ShadowsocksFmt : BaseFmt return null; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs index 250f39e4e07..3883fab83fa 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs @@ -1,4 +1,4 @@ -namespace ServiceLib.Handler.Fmt +namespace ServiceLib.Handler.Fmt { public class SocksFmt : BaseFmt { @@ -23,7 +23,8 @@ public class SocksFmt : BaseFmt public static string? ToUri(ProfileItem? item) { - if (item == null) return null; + if (item == null) + return null; var url = string.Empty; var remark = string.Empty; @@ -86,7 +87,8 @@ public class SocksFmt : BaseFmt private static ProfileItem? ResolveSocksNew(string result) { var parsedUrl = Utils.TryUri(result); - if (parsedUrl == null) return null; + if (parsedUrl == null) + return null; ProfileItem item = new() { @@ -108,4 +110,4 @@ public class SocksFmt : BaseFmt return item; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs index 5a6a208174c..1bd863792c1 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs @@ -1,4 +1,4 @@ -namespace ServiceLib.Handler.Fmt +namespace ServiceLib.Handler.Fmt { public class TrojanFmt : BaseFmt { @@ -12,7 +12,8 @@ public class TrojanFmt : BaseFmt }; var url = Utils.TryUri(str); - if (url == null) return null; + if (url == null) + return null; item.Address = url.IdnHost; item.Port = url.Port; @@ -27,7 +28,8 @@ public class TrojanFmt : BaseFmt public static string? ToUri(ProfileItem? item) { - if (item == null) return null; + if (item == null) + return null; string url = string.Empty; string remark = string.Empty; @@ -41,4 +43,4 @@ public class TrojanFmt : BaseFmt return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Id, dicQuery, remark); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs index 4783716af5f..40993147472 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs @@ -1,4 +1,4 @@ -namespace ServiceLib.Handler.Fmt +namespace ServiceLib.Handler.Fmt { public class TuicFmt : BaseFmt { @@ -12,7 +12,8 @@ public class TuicFmt : BaseFmt }; var url = Utils.TryUri(str); - if (url == null) return null; + if (url == null) + return null; item.Address = url.IdnHost; item.Port = url.Port; @@ -34,7 +35,8 @@ public class TuicFmt : BaseFmt public static string? ToUri(ProfileItem? item) { - if (item == null) return null; + if (item == null) + return null; string url = string.Empty; string remark = string.Empty; @@ -56,4 +58,4 @@ public class TuicFmt : BaseFmt return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Id}:{item.Security}", dicQuery, remark); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs index a84145c3fca..4fc09765162 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs @@ -1,4 +1,4 @@ -namespace ServiceLib.Handler.Fmt +namespace ServiceLib.Handler.Fmt { public class VLESSFmt : BaseFmt { @@ -13,7 +13,8 @@ public class VLESSFmt : BaseFmt }; var url = Utils.TryUri(str); - if (url == null) return null; + if (url == null) + return null; item.Address = url.IdnHost; item.Port = url.Port; @@ -30,7 +31,8 @@ public class VLESSFmt : BaseFmt public static string? ToUri(ProfileItem? item) { - if (item == null) return null; + if (item == null) + return null; string url = string.Empty; string remark = string.Empty; @@ -52,4 +54,4 @@ public class VLESSFmt : BaseFmt return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Id, dicQuery, remark); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs index a9913a3aa1c..a2058aeb083 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs @@ -1,4 +1,4 @@ -namespace ServiceLib.Handler.Fmt +namespace ServiceLib.Handler.Fmt { public class VmessFmt : BaseFmt { @@ -19,7 +19,8 @@ public class VmessFmt : BaseFmt public static string? ToUri(ProfileItem? item) { - if (item == null) return null; + if (item == null) + return null; string url = string.Empty; VmessQRCode vmessQRCode = new() @@ -106,7 +107,8 @@ public class VmessFmt : BaseFmt }; var url = Utils.TryUri(str); - if (url == null) return null; + if (url == null) + return null; item.Address = url.IdnHost; item.Port = url.Port; @@ -119,4 +121,4 @@ public class VmessFmt : BaseFmt return item; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs index e3d88e8cc4c..beb7d933544 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs @@ -1,4 +1,4 @@ -namespace ServiceLib.Handler.Fmt +namespace ServiceLib.Handler.Fmt { public class WireguardFmt : BaseFmt { @@ -12,7 +12,8 @@ public class WireguardFmt : BaseFmt }; var url = Utils.TryUri(str); - if (url == null) return null; + if (url == null) + return null; item.Address = url.IdnHost; item.Port = url.Port; @@ -31,7 +32,8 @@ public class WireguardFmt : BaseFmt public static string? ToUri(ProfileItem? item) { - if (item == null) return null; + if (item == null) + return null; string url = string.Empty; string remark = string.Empty; @@ -60,4 +62,4 @@ public class WireguardFmt : BaseFmt return ToUri(EConfigType.WireGuard, item.Address, item.Port, item.Id, dicQuery, remark); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/PacHandler.cs b/v2rayN/ServiceLib/Handler/PacHandler.cs index f6bf0e28fe6..7eaa59b9e2d 100644 --- a/v2rayN/ServiceLib/Handler/PacHandler.cs +++ b/v2rayN/ServiceLib/Handler/PacHandler.cs @@ -1,4 +1,4 @@ -using System.Net.Sockets; +using System.Net.Sockets; using System.Text; namespace ServiceLib.Handler @@ -89,7 +89,8 @@ private static void WriteContent(TcpClient client) public static void Stop() { - if (_tcpListener == null) return; + if (_tcpListener == null) + return; try { _isRunning = false; @@ -102,4 +103,4 @@ public static void Stop() } } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs index 8d6dbc130f3..be11eae025e 100644 --- a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs +++ b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs @@ -176,7 +176,8 @@ private static bool SetConnectionProxy(string? connectionName, string? strProxy, } // FREE the data ASAP - if (list.szConnection != nint.Zero) Marshal.FreeHGlobal(list.szConnection); // release mem 3 + if (list.szConnection != nint.Zero) + Marshal.FreeHGlobal(list.szConnection); // release mem 3 if (optionCount > 1) { Marshal.FreeHGlobal(options[1].m_Value.m_StringPtr); // release mem 1 @@ -356,4 +357,4 @@ ref int lpcEntries // Number of entries written to the buffer ); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/WebDavHandler.cs b/v2rayN/ServiceLib/Handler/WebDavHandler.cs index d661eb66f3a..8e37fc43591 100644 --- a/v2rayN/ServiceLib/Handler/WebDavHandler.cs +++ b/v2rayN/ServiceLib/Handler/WebDavHandler.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using WebDav; namespace ServiceLib.Handler @@ -61,7 +61,8 @@ private async Task GetClient() private async Task TryCreateDir() { - if (_client is null) return false; + if (_client is null) + return false; try { var result2 = await _client.Mkcol(_webDir); @@ -176,4 +177,4 @@ public async Task GetRawFile(string fileName) public string GetLastError() => _lastDescription ?? string.Empty; } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index ec1ee789714..046989dc322 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -1048,7 +1048,8 @@ private async Task GenRoutingUserRule(RulesItem item, List rules var countDomain = 0; foreach (var it in item.Domain) { - if (ParseV2Domain(it, rule1)) countDomain++; + if (ParseV2Domain(it, rule1)) + countDomain++; } if (countDomain > 0) { @@ -1062,7 +1063,8 @@ private async Task GenRoutingUserRule(RulesItem item, List rules var countIp = 0; foreach (var it in item.Ip) { - if (ParseV2Address(it, rule2)) countIp++; + if (ParseV2Address(it, rule2)) + countIp++; } if (countIp > 0) { @@ -1148,12 +1150,14 @@ private bool ParseV2Address(string address, Rule4Sbox rule) } else if (address.StartsWith("geoip:")) { - if (rule.geoip is null) { rule.geoip = new(); } + if (rule.geoip is null) + { rule.geoip = new(); } rule.geoip?.Add(address.Substring(6)); } else { - if (rule.ip_cidr is null) { rule.ip_cidr = new(); } + if (rule.ip_cidr is null) + { rule.ip_cidr = new(); } rule.ip_cidr?.Add(address); } return true; @@ -1271,7 +1275,8 @@ private async Task ConvertGeo2Ruleset(SingboxConfig singboxConfig) { static void AddRuleSets(List ruleSets, List? rule_set) { - if (rule_set != null) ruleSets.AddRange(rule_set); + if (rule_set != null) + ruleSets.AddRange(rule_set); } var geosite = "geosite"; var geoip = "geoip"; @@ -1339,7 +1344,8 @@ static void AddRuleSets(List ruleSets, List? rule_set) singboxConfig.route.rule_set = []; foreach (var item in new HashSet(ruleSets)) { - if (Utils.IsNullOrEmpty(item)) { continue; } + if (Utils.IsNullOrEmpty(item)) + { continue; } var customRuleset = customRulesets.FirstOrDefault(t => t.tag != null && t.tag.Equals(item)); if (customRuleset is null) { @@ -1378,4 +1384,4 @@ static void AddRuleSets(List ruleSets, List? rule_set) #endregion private gen function } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs index cf134e0188c..10c070eaf00 100644 --- a/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -1,7 +1,7 @@ -using ReactiveUI; using System.Diagnostics; using System.Net; using System.Net.Sockets; +using ReactiveUI; namespace ServiceLib.Services { @@ -119,7 +119,8 @@ private async Task RunAsync(ESpeedActionType actionType, List ls private void ExitLoop(string x) { - if (_exitLoop) return; + if (_exitLoop) + return; _exitLoop = true; UpdateFunc("", ResUI.SpeedtestingStop); } @@ -261,7 +262,8 @@ private async Task RunSpeedTestAsync(List selecteds) UpdateFunc(it.IndexId, "", ResUI.Speedtesting); var item = await AppHandler.Instance.GetProfileItem(it.IndexId); - if (item is null) continue; + if (item is null) + continue; var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}"); @@ -323,7 +325,8 @@ private async Task RunSpeedTestMulti(List selecteds) UpdateFunc(it.IndexId, "", ResUI.Speedtesting); var item = await AppHandler.Instance.GetProfileItem(it.IndexId); - if (item is null) continue; + if (item is null) + continue; var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}"); _ = downloadHandle.DownloadDataAsync(url, webProxy, timeout, (success, msg) => @@ -405,4 +408,4 @@ private void UpdateFunc(string indexId, string delay, string speed = "") _updateFunc?.Invoke(new() { IndexId = indexId, Delay = delay, Speed = speed }); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Services/Statistics/StatisticsSingboxService.cs b/v2rayN/ServiceLib/Services/Statistics/StatisticsSingboxService.cs index 2b5a737a3c3..300bad1a9c7 100644 --- a/v2rayN/ServiceLib/Services/Statistics/StatisticsSingboxService.cs +++ b/v2rayN/ServiceLib/Services/Statistics/StatisticsSingboxService.cs @@ -1,4 +1,4 @@ -using System.Net.WebSockets; +using System.Net.WebSockets; using System.Text; namespace ServiceLib.Services.Statistics @@ -109,7 +109,8 @@ private async void Run() private void ParseOutput(string source, out ulong up, out ulong down) { - up = 0; down = 0; + up = 0; + down = 0; try { var trafficItem = JsonUtils.Deserialize(source); @@ -124,4 +125,4 @@ private void ParseOutput(string source, out ulong up, out ulong down) } } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Services/Statistics/StatisticsXrayService.cs b/v2rayN/ServiceLib/Services/Statistics/StatisticsXrayService.cs index fee5721f4a4..5ee387171a7 100644 --- a/v2rayN/ServiceLib/Services/Statistics/StatisticsXrayService.cs +++ b/v2rayN/ServiceLib/Services/Statistics/StatisticsXrayService.cs @@ -1,4 +1,4 @@ -namespace ServiceLib.Services.Statistics +namespace ServiceLib.Services.Statistics { public class StatisticsXrayService { @@ -63,7 +63,8 @@ private async void Run() foreach (string key in source.stats.outbound.Keys) { var value = source.stats.outbound[key]; - if (value == null) continue; + if (value == null) + continue; var state = JsonUtils.Deserialize(value.ToString()); if (key.StartsWith(Global.ProxyTag)) @@ -102,4 +103,4 @@ private async void Run() return null; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs index 50accd468e9..a37fa46e9bc 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs @@ -1,6 +1,6 @@ +using System.Reactive; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using System.Reactive; namespace ServiceLib.ViewModels { @@ -113,4 +113,4 @@ private async Task EditServer() await Task.CompletedTask; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs index 39c77271ee7..bba48dd3e18 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs @@ -1,6 +1,6 @@ -using ReactiveUI; -using ReactiveUI.Fody.Helpers; using System.Reactive; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; namespace ServiceLib.ViewModels { @@ -94,4 +94,4 @@ private async Task SaveServerAsync() } } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs index 1b7fcc45234..ff74b377408 100644 --- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs @@ -1,7 +1,7 @@ -using ReactiveUI; +using System.Reactive; +using ReactiveUI; using ReactiveUI.Fody.Helpers; using Splat; -using System.Reactive; namespace ServiceLib.ViewModels { @@ -179,4 +179,4 @@ private async Task CreateZipFileFromDirectory(string fileName) return await Task.FromResult(ret); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index a7db1070856..121102df34e 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -1,10 +1,10 @@ -using DynamicData; +using System.Reactive; +using System.Runtime.InteropServices; +using DynamicData; using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; using Splat; -using System.Reactive; -using System.Runtime.InteropServices; namespace ServiceLib.ViewModels { @@ -83,7 +83,8 @@ private async Task CheckUpdate() for (var k = _checkUpdateModel.Count - 1; k >= 0; k--) { var item = _checkUpdateModel[k]; - if (item.IsSelected != true) continue; + if (item.IsSelected != true) + continue; UpdateView(item.CoreType, "..."); if (item.CoreType == _geo) @@ -297,10 +298,11 @@ private void UpdateView(string coreType, string msg) public void UpdateViewResult(CheckUpdateModel model) { var found = _checkUpdateModel.FirstOrDefault(t => t.CoreType == model.CoreType); - if (found == null) return; + if (found == null) + return; var itemCopy = JsonUtils.DeepCopy(found); itemCopy.Remarks = model.Remarks; _checkUpdateModel.Replace(found, itemCopy); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs index cb73ca31260..761fd9b7112 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs @@ -1,9 +1,9 @@ +using System.Reactive; +using System.Reactive.Linq; using DynamicData; using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using System.Reactive; -using System.Reactive.Linq; namespace ServiceLib.ViewModels { @@ -115,7 +115,8 @@ public void RefreshConnections(List? connections) lstModel.Add(model); } - if (lstModel.Count <= 0) { return; } + if (lstModel.Count <= 0) + { return; } _connectionItems.AddRange(lstModel); } @@ -140,4 +141,4 @@ public async Task ClashConnectionClose(bool all) await GetClashConnections(); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index 254d9f48a95..091a42153fe 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -1,9 +1,9 @@ +using System.Reactive; +using System.Reactive.Linq; using DynamicData; using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using System.Reactive; -using System.Reactive.Linq; using static ServiceLib.Models.ClashProviders; using static ServiceLib.Models.ClashProxies; @@ -463,4 +463,4 @@ public async Task DelayTestTask() #endregion task } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index 842a853db24..bf8252f822b 100644 --- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -1,6 +1,6 @@ +using System.Reactive; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using System.Reactive; namespace ServiceLib.ViewModels { @@ -114,4 +114,4 @@ private async Task SaveSettingAsync() _updateView?.Invoke(EViewAction.CloseWindow, null); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 8f60b5b1898..784f7393907 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -1,7 +1,7 @@ +using System.Reactive; using ReactiveUI; using ReactiveUI.Fody.Helpers; using Splat; -using System.Reactive; namespace ServiceLib.ViewModels { @@ -570,7 +570,8 @@ public void ReloadResult() { Locator.Current.GetService()?.ProxiesReload(); } - else { TabMainSelectedIndex = 0; } + else + { TabMainSelectedIndex = 0; } } private async Task LoadCore() @@ -611,4 +612,4 @@ public async Task ApplyRegionalPreset(EPresetType type) #endregion Presets } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs index 54eb6edeaf7..ba3d85e96d9 100644 --- a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs @@ -1,7 +1,7 @@ -using ReactiveUI; -using ReactiveUI.Fody.Helpers; using System.Collections.Concurrent; using System.Text.RegularExpressions; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; namespace ServiceLib.ViewModels { @@ -119,4 +119,4 @@ private void DoMsgFilter() _lastMsgFilterNotAvailable = false; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs index 955adcbe9b3..6dfa40c3f88 100644 --- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -1,6 +1,6 @@ -using ReactiveUI; -using ReactiveUI.Fody.Helpers; using System.Reactive; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; namespace ServiceLib.ViewModels { @@ -415,4 +415,4 @@ private async Task SaveCoreType() await Task.CompletedTask; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 7c8b2d8228e..759ab34d8c5 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -1,11 +1,11 @@ +using System.Reactive; +using System.Reactive.Linq; +using System.Text; using DynamicData; using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; using Splat; -using System.Reactive; -using System.Reactive.Linq; -using System.Text; namespace ServiceLib.ViewModels { @@ -841,4 +841,4 @@ private async Task EditSubAsync(bool blNew) #endregion Subscription } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs index a17ac19c9eb..680be44059e 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs @@ -1,6 +1,6 @@ -using ReactiveUI; -using ReactiveUI.Fody.Helpers; using System.Reactive; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; namespace ServiceLib.ViewModels { @@ -90,4 +90,4 @@ private async Task SaveRulesAsync() await _updateView?.Invoke(EViewAction.CloseWindow, null); } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs index 1dd23893f29..02aa8c57ea0 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs @@ -1,9 +1,9 @@ -using DynamicData.Binding; -using ReactiveUI; -using ReactiveUI.Fody.Helpers; using System.Reactive; using System.Text.Json; using System.Text.Json.Serialization; +using DynamicData.Binding; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; namespace ServiceLib.ViewModels { @@ -338,4 +338,4 @@ private async Task AddBatchRoutingRulesAsync(RoutingItem routingItem, strin #endregion Import rules } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs index 111d249cb8b..b8c7805b2c9 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs @@ -1,7 +1,7 @@ -using DynamicData.Binding; +using System.Reactive; +using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using System.Reactive; namespace ServiceLib.ViewModels { @@ -202,4 +202,4 @@ private async Task RoutingAdvancedImportRules() } } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index 99cf95f2b36..cb49682e133 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -1,9 +1,9 @@ -using DynamicData.Binding; +using System.Reactive; +using System.Text; +using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; using Splat; -using System.Reactive; -using System.Text; namespace ServiceLib.ViewModels { @@ -225,19 +225,22 @@ private async Task CopyProxyCmdToClipboard() private async Task AddServerViaClipboard() { var service = Locator.Current.GetService(); - if (service != null) await service.AddServerViaClipboardAsync(null); + if (service != null) + await service.AddServerViaClipboardAsync(null); } private async Task AddServerViaScan() { var service = Locator.Current.GetService(); - if (service != null) await service.AddServerViaScanAsync(); + if (service != null) + await service.AddServerViaScanAsync(); } private async Task UpdateSubscriptionProcess(bool blProxy) { var service = Locator.Current.GetService(); - if (service != null) await service.UpdateSubscriptionProcess("", blProxy); + if (service != null) + await service.UpdateSubscriptionProcess("", blProxy); } public async Task RefreshServersBiz() @@ -496,4 +499,4 @@ public void UpdateStatistics(ServerSpeedItem update) #endregion UI } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs index 03588adc10a..2bcffa6b513 100644 --- a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs @@ -1,6 +1,6 @@ -using ReactiveUI; -using ReactiveUI.Fody.Helpers; using System.Reactive; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; namespace ServiceLib.ViewModels { @@ -61,4 +61,4 @@ private async Task SaveSubAsync() } } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs index 7b9c11392fb..8b8f964bbb0 100644 --- a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs @@ -1,8 +1,8 @@ -using DynamicData; +using System.Reactive; +using DynamicData; using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using System.Reactive; namespace ServiceLib.ViewModels { @@ -102,4 +102,4 @@ private async Task DeleteSubAsync() IsModified = true; } } -} \ No newline at end of file +} diff --git a/v2rayN/v2rayN.Desktop/App.axaml.cs b/v2rayN/v2rayN.Desktop/App.axaml.cs index 06b59d53a28..c3388125a6c 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml.cs +++ b/v2rayN/v2rayN.Desktop/App.axaml.cs @@ -64,7 +64,8 @@ private async void MenuAddServerViaClipboardClick(object? sender, EventArgs e) { var clipboardData = await AvaUtils.GetClipboardData(desktop.MainWindow); var service = Locator.Current.GetService(); - if (service != null) _ = service.AddServerViaClipboardAsync(clipboardData); + if (service != null) + _ = service.AddServerViaClipboardAsync(clipboardData); } } } @@ -72,7 +73,8 @@ private async void MenuAddServerViaClipboardClick(object? sender, EventArgs e) private async void MenuExit_Click(object? sender, EventArgs e) { var service = Locator.Current.GetService(); - if (service != null) await service.MyAppExitAsync(true); + if (service != null) + await service.MyAppExitAsync(true); service?.Shutdown(true); } -} \ No newline at end of file +} diff --git a/v2rayN/v2rayN.Desktop/Common/AvaUtils.cs b/v2rayN/v2rayN.Desktop/Common/AvaUtils.cs index bd5c5906cc1..ab3d8d8185e 100644 --- a/v2rayN/v2rayN.Desktop/Common/AvaUtils.cs +++ b/v2rayN/v2rayN.Desktop/Common/AvaUtils.cs @@ -1,4 +1,4 @@ -using Avalonia; +using Avalonia; using Avalonia.Controls; using Avalonia.Input; using Avalonia.Media.Imaging; @@ -13,7 +13,8 @@ internal class AvaUtils try { var clipboard = TopLevel.GetTopLevel(owner)?.Clipboard; - if (clipboard == null) return null; + if (clipboard == null) + return null; return await clipboard.GetTextAsync(); } catch @@ -27,7 +28,8 @@ public static async Task SetClipboardData(Visual? visual, string strData) try { var clipboard = TopLevel.GetTopLevel(visual)?.Clipboard; - if (clipboard == null) return; + if (clipboard == null) + return; var dataObject = new DataObject(); dataObject.Set(DataFormats.Text, strData); await clipboard.SetDataObjectAsync(dataObject); @@ -51,4 +53,4 @@ public static WindowIcon GetAppIcon(ESysProxyType sysProxyType) return new(bitmap); } } -} \ No newline at end of file +} diff --git a/v2rayN/v2rayN.Desktop/Common/UI.cs b/v2rayN/v2rayN.Desktop/Common/UI.cs index 74cfa6ebf8d..0b7cf2b4717 100644 --- a/v2rayN/v2rayN.Desktop/Common/UI.cs +++ b/v2rayN/v2rayN.Desktop/Common/UI.cs @@ -1,4 +1,4 @@ -using Avalonia.Controls; +using Avalonia.Controls; using Avalonia.Platform.Storage; using MsBox.Avalonia; using MsBox.Avalonia.Enums; @@ -18,8 +18,9 @@ public static async Task ShowYesNo(Window owner, string msg) public static async Task OpenFileDialog(Window owner, FilePickerFileType? filter) { var sp = GetStorageProvider(owner); - if (sp is null) return null; - + if (sp is null) + return null; + // Start async operation to open the dialog. var files = await sp.OpenFilePickerAsync(new FilePickerOpenOptions { @@ -33,7 +34,8 @@ public static async Task ShowYesNo(Window owner, string msg) public static async Task SaveFileDialog(Window owner, string filter) { var sp = GetStorageProvider(owner); - if (sp is null) return null; + if (sp is null) + return null; // Start async operation to open the dialog. var files = await sp.SaveFilePickerAsync(new FilePickerSaveOptions @@ -49,4 +51,4 @@ public static async Task ShowYesNo(Window owner, string msg) return topLevel?.StorageProvider; } } -} \ No newline at end of file +} diff --git a/v2rayN/v2rayN.Desktop/Converters/DelayColorConverter.cs b/v2rayN/v2rayN.Desktop/Converters/DelayColorConverter.cs index e61425f5bd5..3f1e20640e4 100644 --- a/v2rayN/v2rayN.Desktop/Converters/DelayColorConverter.cs +++ b/v2rayN/v2rayN.Desktop/Converters/DelayColorConverter.cs @@ -1,6 +1,6 @@ -using Avalonia.Data.Converters; -using Avalonia.Media; using System.Globalization; +using Avalonia.Data.Converters; +using Avalonia.Media; namespace v2rayN.Desktop.Converters { @@ -23,4 +23,4 @@ public class DelayColorConverter : IValueConverter return null; } } -} \ No newline at end of file +} diff --git a/v2rayN/v2rayN.Desktop/Program.cs b/v2rayN/v2rayN.Desktop/Program.cs index 3039895cf3a..acc7a3321fe 100644 --- a/v2rayN/v2rayN.Desktop/Program.cs +++ b/v2rayN/v2rayN.Desktop/Program.cs @@ -53,5 +53,5 @@ public static AppBuilder BuildAvaloniaApp() .WithFontByDefault() .LogToTrace() .UseReactiveUI() - .With(new MacOSPlatformOptions { ShowInDock = false}); -} \ No newline at end of file + .With(new MacOSPlatformOptions { ShowInDock = false }); +} diff --git a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs index afdf78c2c50..6a680956645 100644 --- a/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs +++ b/v2rayN/v2rayN.Desktop/ViewModels/ThemeSettingViewModel.cs @@ -1,3 +1,4 @@ +using System.Reactive.Linq; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Notifications; @@ -7,7 +8,6 @@ using ReactiveUI; using ReactiveUI.Fody.Helpers; using Semi.Avalonia; -using System.Reactive.Linq; namespace v2rayN.Desktop.ViewModels { @@ -100,7 +100,8 @@ private void ModifyTheme() private void ModifyFontSize() { double size = CurrentFontSize; - if (size < Global.MinFontSize) return; + if (size < Global.MinFontSize) + return; Style style = new(x => Selectors.Or( x.OfType