diff --git a/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs index 2fa844a2..2e52130e 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs @@ -215,7 +215,9 @@ namespace ServiceLib.Handler.Fmt foreach (var item in s) { if (str.Contains(item, StringComparison.OrdinalIgnoreCase)) + { return true; + } } return false; } diff --git a/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs index 98be504d..d35226e9 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs @@ -27,10 +27,10 @@ namespace ServiceLib.Handler.Fmt public static string? ToUri(ProfileItem? item) { if (item == null) + { return null; - string url = string.Empty; - - string remark = string.Empty; + } + var remark = string.Empty; if (item.Remarks.IsNotEmpty()) { remark = "#" + Utils.UrlEncode(item.Remarks); @@ -53,7 +53,9 @@ namespace ServiceLib.Handler.Fmt { var match = UrlFinder.Match(result); if (!match.Success) + { return null; + } ProfileItem item = new(); var base64 = match.Groups["base64"].Value.TrimEnd('/'); @@ -72,7 +74,9 @@ namespace ServiceLib.Handler.Fmt return null; } if (!details.Success) + { return null; + } item.Security = details.Groups["method"].Value; item.Id = details.Groups["password"].Value; item.Address = details.Groups["hostname"].Value; @@ -84,7 +88,9 @@ namespace ServiceLib.Handler.Fmt { var parsedUrl = Utils.TryUri(result); if (parsedUrl == null) + { return null; + } ProfileItem item = new() { @@ -96,7 +102,7 @@ namespace ServiceLib.Handler.Fmt //2022-blake3 if (rawUserInfo.Contains(':')) { - string[] userInfoParts = rawUserInfo.Split(new[] { ':' }, 2); + var userInfoParts = rawUserInfo.Split(new[] { ':' }, 2); if (userInfoParts.Length != 2) { return null; @@ -107,8 +113,8 @@ namespace ServiceLib.Handler.Fmt else { // parse base64 UserInfo - string userInfo = Utils.Base64Decode(rawUserInfo); - string[] userInfoParts = userInfo.Split(new[] { ':' }, 2); + var userInfo = Utils.Base64Decode(rawUserInfo); + var userInfoParts = userInfo.Split(new[] { ':' }, 2); if (userInfoParts.Length != 2) { return null; diff --git a/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs index e3540872..07098d2b 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs @@ -1,10 +1,10 @@ -namespace ServiceLib.Handler.Fmt +namespace ServiceLib.Handler.Fmt { public class SingboxFmt : BaseFmt { public static List? ResolveFullArray(string strData, string? subRemarks) { - var configObjects = JsonUtils.Deserialize(strData); + var configObjects = JsonUtils.Deserialize(strData); if (configObjects != null && configObjects.Length > 0) { List lstResult = []; @@ -52,4 +52,4 @@ 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 f13cccbb..9527bb56 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs @@ -24,9 +24,9 @@ namespace ServiceLib.Handler.Fmt public static string? ToUri(ProfileItem? item) { if (item == null) + { return null; - var url = string.Empty; - + } var remark = string.Empty; if (item.Remarks.IsNotEmpty()) { @@ -77,7 +77,7 @@ namespace ServiceLib.Handler.Fmt return null; } item.Address = arr1[1][..indexPort]; - item.Port = (arr1[1][(indexPort + 1)..]).ToInt(); + item.Port = arr1[1][(indexPort + 1)..].ToInt(); item.Security = arr21.First(); item.Id = arr21[1]; @@ -88,7 +88,9 @@ namespace ServiceLib.Handler.Fmt { var parsedUrl = Utils.TryUri(result); if (parsedUrl == null) + { return null; + } ProfileItem item = new() { diff --git a/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs index afcaa194..60f05764 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs @@ -13,7 +13,9 @@ namespace ServiceLib.Handler.Fmt var url = Utils.TryUri(str); if (url == null) + { return null; + } item.Address = url.IdnHost; item.Port = url.Port; @@ -21,7 +23,7 @@ namespace ServiceLib.Handler.Fmt item.Id = Utils.UrlDecode(url.UserInfo); var query = Utils.ParseQueryString(url.Query); - ResolveStdTransport(query, ref item); + _ = ResolveStdTransport(query, ref item); return item; } @@ -29,16 +31,16 @@ namespace ServiceLib.Handler.Fmt public static string? ToUri(ProfileItem? item) { if (item == null) + { return null; - string url = string.Empty; - - string remark = string.Empty; + } + var remark = string.Empty; if (item.Remarks.IsNotEmpty()) { remark = "#" + Utils.UrlEncode(item.Remarks); } var dicQuery = new Dictionary(); - GetStdTransport(item, null, ref dicQuery); + _ = GetStdTransport(item, null, ref dicQuery); return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Id, dicQuery, remark); } diff --git a/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs index 8fc23fbd..39f52d7b 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs @@ -13,7 +13,9 @@ namespace ServiceLib.Handler.Fmt var url = Utils.TryUri(str); if (url == null) + { return null; + } item.Address = url.IdnHost; item.Port = url.Port; @@ -36,10 +38,11 @@ namespace ServiceLib.Handler.Fmt public static string? ToUri(ProfileItem? item) { if (item == null) + { return null; - string url = string.Empty; + } - string remark = string.Empty; + var remark = string.Empty; if (item.Remarks.IsNotEmpty()) { remark = "#" + Utils.UrlEncode(item.Remarks); diff --git a/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs index cc2ec7bf..ee5c8512 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs @@ -1,10 +1,10 @@ -namespace ServiceLib.Handler.Fmt +namespace ServiceLib.Handler.Fmt { public class V2rayFmt : BaseFmt { public static List? ResolveFullArray(string strData, string? subRemarks) { - var configObjects = JsonUtils.Deserialize(strData); + var configObjects = JsonUtils.Deserialize(strData); if (configObjects != null && configObjects.Length > 0) { List lstResult = []; @@ -53,4 +53,4 @@ return null; } } -} \ No newline at end of file +} diff --git a/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs index 20899afb..819c50b6 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs @@ -14,7 +14,9 @@ namespace ServiceLib.Handler.Fmt var url = Utils.TryUri(str); if (url == null) + { return null; + } item.Address = url.IdnHost; item.Port = url.Port; @@ -24,7 +26,7 @@ namespace ServiceLib.Handler.Fmt var query = Utils.ParseQueryString(url.Query); item.Security = query["encryption"] ?? Global.None; item.StreamSecurity = query["security"] ?? ""; - ResolveStdTransport(query, ref item); + _ = ResolveStdTransport(query, ref item); return item; } @@ -32,10 +34,11 @@ namespace ServiceLib.Handler.Fmt public static string? ToUri(ProfileItem? item) { if (item == null) + { return null; - string url = string.Empty; + } - string remark = string.Empty; + var remark = string.Empty; if (item.Remarks.IsNotEmpty()) { remark = "#" + Utils.UrlEncode(item.Remarks); @@ -49,7 +52,7 @@ namespace ServiceLib.Handler.Fmt { dicQuery.Add("encryption", Global.None); } - GetStdTransport(item, Global.None, ref dicQuery); + _ = GetStdTransport(item, Global.None, ref dicQuery); return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Id, dicQuery, remark); } diff --git a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs index cf1eaa62..47bf297d 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs @@ -20,10 +20,10 @@ namespace ServiceLib.Handler.Fmt public static string? ToUri(ProfileItem? item) { if (item == null) + { return null; - string url = string.Empty; - - VmessQRCode vmessQRCode = new() + } + var vmessQRCode = new VmessQRCode { v = item.ConfigVersion, ps = item.Remarks.TrimEx(), @@ -42,7 +42,7 @@ namespace ServiceLib.Handler.Fmt fp = item.Fingerprint }; - url = JsonUtils.Serialize(vmessQRCode); + var url = JsonUtils.Serialize(vmessQRCode); url = Utils.Base64Encode(url); url = $"{Global.ProtocolShares[EConfigType.VMess]}{url}"; @@ -60,7 +60,7 @@ namespace ServiceLib.Handler.Fmt result = result[Global.ProtocolShares[EConfigType.VMess].Length..]; result = Utils.Base64Decode(result); - VmessQRCode? vmessQRCode = JsonUtils.Deserialize(result); + var vmessQRCode = JsonUtils.Deserialize(result); if (vmessQRCode == null) { msg = ResUI.FailedConversionConfiguration; @@ -100,7 +100,7 @@ namespace ServiceLib.Handler.Fmt public static ProfileItem? ResolveStdVmess(string str) { - ProfileItem item = new() + var item = new ProfileItem { ConfigType = EConfigType.VMess, Security = "auto" @@ -108,7 +108,9 @@ namespace ServiceLib.Handler.Fmt var url = Utils.TryUri(str); if (url == null) + { return null; + } item.Address = url.IdnHost; item.Port = url.Port; diff --git a/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs index f36741ed..d7083963 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs @@ -13,7 +13,9 @@ namespace ServiceLib.Handler.Fmt var url = Utils.TryUri(str); if (url == null) + { return null; + } item.Address = url.IdnHost; item.Port = url.Port; @@ -33,10 +35,11 @@ namespace ServiceLib.Handler.Fmt public static string? ToUri(ProfileItem? item) { if (item == null) + { return null; - string url = string.Empty; + } - string remark = string.Empty; + var remark = string.Empty; if (item.Remarks.IsNotEmpty()) { remark = "#" + Utils.UrlEncode(item.Remarks);