mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-14 20:28:11 +00:00
Replace all Utils.IsNullOrEmpty(variable) with variable.IsNullOrEmpty()
This commit is contained in:
parent
f3af831cf2
commit
71cc6d7a88
34 changed files with 153 additions and 162 deletions
|
@ -10,7 +10,7 @@ namespace ServiceLib.Common
|
||||||
|
|
||||||
public async Task<string?> DownloadStringAsync(IWebProxy? webProxy, string url, string? userAgent, int timeout)
|
public async Task<string?> DownloadStringAsync(IWebProxy? webProxy, string url, string? userAgent, int timeout)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace ServiceLib.Common
|
||||||
|
|
||||||
public async Task DownloadDataAsync4Speed(IWebProxy webProxy, string url, IProgress<string> progress, int timeout)
|
public async Task DownloadDataAsync4Speed(IWebProxy webProxy, string url, IProgress<string> progress, int timeout)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(url));
|
throw new ArgumentNullException(nameof(url));
|
||||||
}
|
}
|
||||||
|
@ -119,11 +119,11 @@ namespace ServiceLib.Common
|
||||||
|
|
||||||
public async Task DownloadFileAsync(IWebProxy? webProxy, string url, string fileName, IProgress<double> progress, int timeout)
|
public async Task DownloadFileAsync(IWebProxy? webProxy, string url, string fileName, IProgress<double> progress, int timeout)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(url));
|
throw new ArgumentNullException(nameof(url));
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(fileName));
|
throw new ArgumentNullException(nameof(fileName));
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace ServiceLib.Common
|
||||||
|
|
||||||
public async Task<string?> TryGetAsync(string url)
|
public async Task<string?> TryGetAsync(string url)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -38,14 +38,14 @@ namespace ServiceLib.Common
|
||||||
|
|
||||||
public async Task<string?> GetAsync(string url)
|
public async Task<string?> GetAsync(string url)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
return null;
|
return null;
|
||||||
return await httpClient.GetStringAsync(url);
|
return await httpClient.GetStringAsync(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string?> GetAsync(HttpClient client, string url, CancellationToken token = default)
|
public async Task<string?> GetAsync(HttpClient client, string url, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
return null;
|
return null;
|
||||||
return await client.GetStringAsync(url, token);
|
return await client.GetStringAsync(url, token);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ namespace ServiceLib.Common
|
||||||
|
|
||||||
public async Task DownloadDataAsync4Speed(HttpClient client, string url, IProgress<string> progress, CancellationToken token = default)
|
public async Task DownloadDataAsync4Speed(HttpClient client, string url, IProgress<string> progress, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(url));
|
throw new ArgumentNullException(nameof(url));
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,7 @@ namespace ServiceLib.Common
|
||||||
public static NameValueCollection ParseQueryString(string query)
|
public static NameValueCollection ParseQueryString(string query)
|
||||||
{
|
{
|
||||||
var result = new NameValueCollection(StringComparer.OrdinalIgnoreCase);
|
var result = new NameValueCollection(StringComparer.OrdinalIgnoreCase);
|
||||||
if (IsNullOrEmpty(query))
|
if (query.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ namespace ServiceLib.Common
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GetPunycode(string url)
|
public static string GetPunycode(string url)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ namespace ServiceLib.Common
|
||||||
|
|
||||||
public static string Convert2Comma(string text)
|
public static string Convert2Comma(string text)
|
||||||
{
|
{
|
||||||
if (IsNullOrEmpty(text))
|
if (text.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -353,15 +353,6 @@ namespace ServiceLib.Common
|
||||||
return oText.All(char.IsNumber);
|
return oText.All(char.IsNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsNullOrEmpty(string? text)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(text))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return text == "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证Domain地址是否合法
|
/// 验证Domain地址是否合法
|
||||||
|
@ -369,7 +360,7 @@ namespace ServiceLib.Common
|
||||||
/// <param name="domain"></param>
|
/// <param name="domain"></param>
|
||||||
public static bool IsDomain(string? domain)
|
public static bool IsDomain(string? domain)
|
||||||
{
|
{
|
||||||
if (IsNullOrEmpty(domain))
|
if (domain.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -655,7 +646,7 @@ namespace ServiceLib.Common
|
||||||
public static string GetPath(string fileName)
|
public static string GetPath(string fileName)
|
||||||
{
|
{
|
||||||
var startupPath = StartupPath();
|
var startupPath = StartupPath();
|
||||||
if (IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return startupPath;
|
return startupPath;
|
||||||
}
|
}
|
||||||
|
@ -691,7 +682,7 @@ namespace ServiceLib.Common
|
||||||
Directory.CreateDirectory(tempPath);
|
Directory.CreateDirectory(tempPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsNullOrEmpty(filename))
|
if (filename.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return tempPath;
|
return tempPath;
|
||||||
}
|
}
|
||||||
|
@ -720,7 +711,7 @@ namespace ServiceLib.Common
|
||||||
Directory.CreateDirectory(tempPath);
|
Directory.CreateDirectory(tempPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(filename))
|
if (filename.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return tempPath;
|
return tempPath;
|
||||||
}
|
}
|
||||||
|
@ -747,7 +738,7 @@ namespace ServiceLib.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsNullOrEmpty(filename))
|
if (filename.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return tempPath;
|
return tempPath;
|
||||||
}
|
}
|
||||||
|
@ -765,7 +756,7 @@ namespace ServiceLib.Common
|
||||||
Directory.CreateDirectory(tempPath);
|
Directory.CreateDirectory(tempPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(filename))
|
if (filename.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return tempPath;
|
return tempPath;
|
||||||
}
|
}
|
||||||
|
@ -783,7 +774,7 @@ namespace ServiceLib.Common
|
||||||
Directory.CreateDirectory(tempPath);
|
Directory.CreateDirectory(tempPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(filename))
|
if (filename.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return tempPath;
|
return tempPath;
|
||||||
}
|
}
|
||||||
|
@ -801,7 +792,7 @@ namespace ServiceLib.Common
|
||||||
Directory.CreateDirectory(tempPath);
|
Directory.CreateDirectory(tempPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(filename))
|
if (filename.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return tempPath;
|
return tempPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace ServiceLib.Common
|
||||||
{
|
{
|
||||||
regKey = Registry.CurrentUser.OpenSubKey(path, false);
|
regKey = Registry.CurrentUser.OpenSubKey(path, false);
|
||||||
var value = regKey?.GetValue(name) as string;
|
var value = regKey?.GetValue(name) as string;
|
||||||
return Utils.IsNullOrEmpty(value) ? def : value;
|
return value.IsNullOrEmpty() ? def : value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ namespace ServiceLib.Common
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
regKey = Registry.CurrentUser.CreateSubKey(path);
|
regKey = Registry.CurrentUser.CreateSubKey(path);
|
||||||
if (Utils.IsNullOrEmpty(value.ToString()))
|
if (value.ToString().IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
regKey?.DeleteValue(name, false);
|
regKey?.DeleteValue(name, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
public async Task<List<ProfileItem>?> ProfileItems(string subid)
|
public async Task<List<ProfileItem>?> ProfileItems(string subid)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(subid))
|
if (subid.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return await SQLiteHelper.Instance.TableAsync<ProfileItem>().ToListAsync();
|
return await SQLiteHelper.Instance.TableAsync<ProfileItem>().ToListAsync();
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
public async Task<ProfileItem?> GetProfileItem(string indexId)
|
public async Task<ProfileItem?> GetProfileItem(string indexId)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(indexId))
|
if (indexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
public async Task<ProfileItem?> GetProfileItemViaRemarks(string? remarks)
|
public async Task<ProfileItem?> GetProfileItemViaRemarks(string? remarks)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(remarks))
|
if (remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace ServiceLib.Handler
|
||||||
/// <exception cref="ArgumentNullException"></exception>
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
public static void AutoStartTaskService(string taskName, string fileName, string description)
|
public static void AutoStartTaskService(string taskName, string fileName, string description)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(taskName))
|
if (taskName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ namespace ServiceLib.Handler
|
||||||
var logonUser = WindowsIdentity.GetCurrent().Name;
|
var logonUser = WindowsIdentity.GetCurrent().Name;
|
||||||
using var taskService = new Microsoft.Win32.TaskScheduler.TaskService();
|
using var taskService = new Microsoft.Win32.TaskScheduler.TaskService();
|
||||||
var tasks = taskService.RootFolder.GetTasks(new Regex(taskName));
|
var tasks = taskService.RootFolder.GetTasks(new Regex(taskName));
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
foreach (var t in tasks)
|
foreach (var t in tasks)
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace ServiceLib.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
config.RoutingBasicItem ??= new();
|
config.RoutingBasicItem ??= new();
|
||||||
if (Utils.IsNullOrEmpty(config.RoutingBasicItem.DomainStrategy))
|
if (config.RoutingBasicItem.DomainStrategy.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
config.RoutingBasicItem.DomainStrategy = Global.DomainStrategies.First();
|
config.RoutingBasicItem.DomainStrategy = Global.DomainStrategies.First();
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ namespace ServiceLib.Handler
|
||||||
};
|
};
|
||||||
config.UiItem.MainColumnItem ??= new();
|
config.UiItem.MainColumnItem ??= new();
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(config.UiItem.CurrentLanguage))
|
if (config.UiItem.CurrentLanguage.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
config.UiItem.CurrentLanguage = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Equals("zh", StringComparison.CurrentCultureIgnoreCase)
|
config.UiItem.CurrentLanguage = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Equals("zh", StringComparison.CurrentCultureIgnoreCase)
|
||||||
? Global.Languages.First()
|
? Global.Languages.First()
|
||||||
|
@ -117,11 +117,11 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
config.SpeedTestItem.SpeedTestTimeout = 10;
|
config.SpeedTestItem.SpeedTestTimeout = 10;
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(config.SpeedTestItem.SpeedTestUrl))
|
if (config.SpeedTestItem.SpeedTestUrl.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
config.SpeedTestItem.SpeedTestUrl = Global.SpeedTestUrls.First();
|
config.SpeedTestItem.SpeedTestUrl = Global.SpeedTestUrls.First();
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(config.SpeedTestItem.SpeedPingTestUrl))
|
if (config.SpeedTestItem.SpeedPingTestUrl.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
config.SpeedTestItem.SpeedPingTestUrl = Global.SpeedPingTestUrl;
|
config.SpeedTestItem.SpeedPingTestUrl = Global.SpeedPingTestUrl;
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ namespace ServiceLib.Handler
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<int> SetDefaultServerIndex(Config config, string? indexId)
|
public static async Task<int> SetDefaultServerIndex(Config config, string? indexId)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(indexId))
|
if (indexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
profileItem.Address = newFileName;
|
profileItem.Address = newFileName;
|
||||||
profileItem.ConfigType = EConfigType.Custom;
|
profileItem.ConfigType = EConfigType.Custom;
|
||||||
if (Utils.IsNullOrEmpty(profileItem.Remarks))
|
if (profileItem.Remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
profileItem.Remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}";
|
profileItem.Remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}";
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
profileItem.Address = profileItem.Address.TrimEx();
|
profileItem.Address = profileItem.Address.TrimEx();
|
||||||
profileItem.Id = profileItem.Id.TrimEx();
|
profileItem.Id = profileItem.Id.TrimEx();
|
||||||
if (Utils.IsNullOrEmpty(profileItem.StreamSecurity))
|
if (profileItem.StreamSecurity.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
profileItem.StreamSecurity = Global.StreamSecurity;
|
profileItem.StreamSecurity = Global.StreamSecurity;
|
||||||
}
|
}
|
||||||
|
@ -654,7 +654,7 @@ namespace ServiceLib.Handler
|
||||||
profileItem.Path = profileItem.Path.TrimEx();
|
profileItem.Path = profileItem.Path.TrimEx();
|
||||||
profileItem.Network = string.Empty;
|
profileItem.Network = string.Empty;
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(profileItem.StreamSecurity))
|
if (profileItem.StreamSecurity.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
profileItem.StreamSecurity = Global.StreamSecurity;
|
profileItem.StreamSecurity = Global.StreamSecurity;
|
||||||
}
|
}
|
||||||
|
@ -689,11 +689,11 @@ namespace ServiceLib.Handler
|
||||||
profileItem.HeaderType = Global.TuicCongestionControls.FirstOrDefault()!;
|
profileItem.HeaderType = Global.TuicCongestionControls.FirstOrDefault()!;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(profileItem.StreamSecurity))
|
if (profileItem.StreamSecurity.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
profileItem.StreamSecurity = Global.StreamSecurity;
|
profileItem.StreamSecurity = Global.StreamSecurity;
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(profileItem.Alpn))
|
if (profileItem.Alpn.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
profileItem.Alpn = "h3";
|
profileItem.Alpn = "h3";
|
||||||
}
|
}
|
||||||
|
@ -906,11 +906,11 @@ namespace ServiceLib.Handler
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(profileItem.AllowInsecure))
|
if (profileItem.AllowInsecure.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
profileItem.AllowInsecure = config.CoreBasicItem.DefAllowInsecure.ToString().ToLower();
|
profileItem.AllowInsecure = config.CoreBasicItem.DefAllowInsecure.ToString().ToLower();
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(profileItem.Fingerprint) && profileItem.StreamSecurity == Global.StreamSecurityReality)
|
if (profileItem.Fingerprint.IsNullOrEmpty() && profileItem.StreamSecurity == Global.StreamSecurityReality)
|
||||||
{
|
{
|
||||||
profileItem.Fingerprint = config.CoreBasicItem.DefFingerprint;
|
profileItem.Fingerprint = config.CoreBasicItem.DefFingerprint;
|
||||||
}
|
}
|
||||||
|
@ -923,7 +923,7 @@ namespace ServiceLib.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxSort = -1;
|
var maxSort = -1;
|
||||||
if (Utils.IsNullOrEmpty(profileItem.IndexId))
|
if (profileItem.IndexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
profileItem.IndexId = Utils.GetGuid(false);
|
profileItem.IndexId = Utils.GetGuid(false);
|
||||||
maxSort = ProfileExHandler.Instance.GetMaxSort();
|
maxSort = ProfileExHandler.Instance.GetMaxSort();
|
||||||
|
@ -1084,7 +1084,7 @@ namespace ServiceLib.Handler
|
||||||
/// <returns>成功导入的数量</returns>
|
/// <returns>成功导入的数量</returns>
|
||||||
private static async Task<int> AddBatchServersCommon(Config config, string strData, string subid, bool isSub)
|
private static async Task<int> AddBatchServersCommon(Config config, string strData, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(strData))
|
if (strData.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1163,7 +1163,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
private static async Task<int> AddBatchServers4Custom(Config config, string strData, string subid, bool isSub)
|
private static async Task<int> AddBatchServers4Custom(Config config, string strData, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(strData))
|
if (strData.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1236,7 +1236,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
profileItem = NaiveproxyFmt.ResolveFull(strData, subRemarks);
|
profileItem = NaiveproxyFmt.ResolveFull(strData, subRemarks);
|
||||||
}
|
}
|
||||||
if (profileItem is null || Utils.IsNullOrEmpty(profileItem.Address))
|
if (profileItem is null || profileItem.Address.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1261,7 +1261,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
private static async Task<int> AddBatchServers4SsSIP008(Config config, string strData, string subid, bool isSub)
|
private static async Task<int> AddBatchServers4SsSIP008(Config config, string strData, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(strData))
|
if (strData.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1293,7 +1293,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
public static async Task<int> AddBatchServers(Config config, string strData, string subid, bool isSub)
|
public static async Task<int> AddBatchServers(Config config, string strData, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(strData))
|
if (strData.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1424,7 +1424,7 @@ namespace ServiceLib.Handler
|
||||||
item.Memo = subItem.Memo;
|
item.Memo = subItem.Memo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(item.Id))
|
if (item.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
item.Id = Utils.GetGuid(false);
|
item.Id = Utils.GetGuid(false);
|
||||||
|
|
||||||
|
@ -1457,7 +1457,7 @@ namespace ServiceLib.Handler
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<int> RemoveServersViaSubid(Config config, string subid, bool isSub)
|
public static async Task<int> RemoveServersViaSubid(Config config, string subid, bool isSub)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(subid))
|
if (subid.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1508,7 +1508,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
public static async Task<int> SaveRoutingItem(Config config, RoutingItem item)
|
public static async Task<int> SaveRoutingItem(Config config, RoutingItem item)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(item.Id))
|
if (item.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
item.Id = Utils.GetGuid(false);
|
item.Id = Utils.GetGuid(false);
|
||||||
}
|
}
|
||||||
|
@ -1531,7 +1531,7 @@ namespace ServiceLib.Handler
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<int> AddBatchRoutingRules(RoutingItem routingItem, string strData)
|
public static async Task<int> AddBatchRoutingRules(RoutingItem routingItem, string strData)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(strData))
|
if (strData.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1549,7 +1549,7 @@ namespace ServiceLib.Handler
|
||||||
routingItem.RuleNum = lstRules.Count;
|
routingItem.RuleNum = lstRules.Count;
|
||||||
routingItem.RuleSet = JsonUtils.Serialize(lstRules, false);
|
routingItem.RuleSet = JsonUtils.Serialize(lstRules, false);
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(routingItem.Id))
|
if (routingItem.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
routingItem.Id = Utils.GetGuid(false);
|
routingItem.Id = Utils.GetGuid(false);
|
||||||
}
|
}
|
||||||
|
@ -1820,7 +1820,7 @@ namespace ServiceLib.Handler
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(item.Id))
|
if (item.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
item.Id = Utils.GetGuid(false);
|
item.Id = Utils.GetGuid(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ namespace ServiceLib.Handler
|
||||||
private async Task<Process?> RunProcess(CoreInfo? coreInfo, string configPath, bool displayLog, bool mayNeedSudo)
|
private async Task<Process?> RunProcess(CoreInfo? coreInfo, string configPath, bool displayLog, bool mayNeedSudo)
|
||||||
{
|
{
|
||||||
var fileName = CoreInfoHandler.Instance.GetCoreExecFile(coreInfo, out var msg);
|
var fileName = CoreInfoHandler.Instance.GetCoreExecFile(coreInfo, out var msg);
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
UpdateFunc(false, msg);
|
UpdateFunc(false, msg);
|
||||||
return null;
|
return null;
|
||||||
|
@ -274,13 +274,13 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
proc.OutputDataReceived += (sender, e) =>
|
proc.OutputDataReceived += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(e.Data))
|
if (e.Data.IsNullOrEmpty())
|
||||||
return;
|
return;
|
||||||
UpdateFunc(false, e.Data + Environment.NewLine);
|
UpdateFunc(false, e.Data + Environment.NewLine);
|
||||||
};
|
};
|
||||||
proc.ErrorDataReceived += (sender, e) =>
|
proc.ErrorDataReceived += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(e.Data))
|
if (e.Data.IsNullOrEmpty())
|
||||||
return;
|
return;
|
||||||
UpdateFunc(false, e.Data + Environment.NewLine);
|
UpdateFunc(false, e.Data + Environment.NewLine);
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string str = config.TrimEx();
|
string str = config.TrimEx();
|
||||||
if (Utils.IsNullOrEmpty(str))
|
if (str.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
msg = ResUI.FailedReadConfiguration;
|
msg = ResUI.FailedReadConfiguration;
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
strProxy = string.Empty;
|
strProxy = string.Empty;
|
||||||
if (Utils.IsNullOrEmpty(config.SystemProxyItem.SystemProxyAdvancedProtocol))
|
if (config.SystemProxyItem.SystemProxyAdvancedProtocol.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
strProxy = $"{Global.Loopback}:{port}";
|
strProxy = $"{Global.Loopback}:{port}";
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,12 +48,12 @@ namespace ServiceLib.Models
|
||||||
|
|
||||||
public List<string>? GetAlpn()
|
public List<string>? GetAlpn()
|
||||||
{
|
{
|
||||||
return Utils.IsNullOrEmpty(Alpn) ? null : Utils.String2List(Alpn);
|
return Alpn.IsNullOrEmpty() ? null : Utils.String2List(Alpn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetNetwork()
|
public string GetNetwork()
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(Network) || !Global.Networks.Contains(Network))
|
if (Network.IsNullOrEmpty() || !Global.Networks.Contains(Network))
|
||||||
{
|
{
|
||||||
return Global.DefaultNetwork;
|
return Global.DefaultNetwork;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
string addressFileName = node.Address;
|
string addressFileName = node.Address;
|
||||||
if (Utils.IsNullOrEmpty(addressFileName))
|
if (addressFileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
ret.Msg = ResUI.InitialConfiguration;
|
ret.Msg = ResUI.InitialConfiguration;
|
||||||
|
|
||||||
string result = EmbedUtils.GetEmbedText(Global.SingboxSampleClient);
|
string result = EmbedUtils.GetEmbedText(Global.SingboxSampleClient);
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -93,7 +93,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
|
|
||||||
var result = EmbedUtils.GetEmbedText(Global.SingboxSampleClient);
|
var result = EmbedUtils.GetEmbedText(Global.SingboxSampleClient);
|
||||||
var txtOutbound = EmbedUtils.GetEmbedText(Global.SingboxSampleOutbound);
|
var txtOutbound = EmbedUtils.GetEmbedText(Global.SingboxSampleOutbound);
|
||||||
if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
|
if (result.IsNullOrEmpty() || txtOutbound.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -138,7 +138,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
|
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
|
||||||
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
||||||
{
|
{
|
||||||
if (item is null || Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id))
|
if (item is null || item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
ret.Msg = ResUI.InitialConfiguration;
|
ret.Msg = ResUI.InitialConfiguration;
|
||||||
|
|
||||||
var result = EmbedUtils.GetEmbedText(Global.SingboxSampleClient);
|
var result = EmbedUtils.GetEmbedText(Global.SingboxSampleClient);
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -317,7 +317,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
|
|
||||||
string result = EmbedUtils.GetEmbedText(Global.SingboxSampleClient);
|
string result = EmbedUtils.GetEmbedText(Global.SingboxSampleClient);
|
||||||
string txtOutbound = EmbedUtils.GetEmbedText(Global.SingboxSampleOutbound);
|
string txtOutbound = EmbedUtils.GetEmbedText(Global.SingboxSampleOutbound);
|
||||||
if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
|
if (result.IsNullOrEmpty() || txtOutbound.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -354,7 +354,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id))
|
if (item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
string addressFileName = node.Address;
|
string addressFileName = node.Address;
|
||||||
if (Utils.IsNullOrEmpty(addressFileName))
|
if (addressFileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -560,7 +560,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
inbound.listen_port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
|
inbound.listen_port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||||
inbound.sniff = _config.Inbound.First().SniffingEnabled;
|
inbound.sniff = _config.Inbound.First().SniffingEnabled;
|
||||||
inbound.sniff_override_destination = _config.Inbound.First().RouteOnly ? false : _config.Inbound.First().SniffingEnabled;
|
inbound.sniff_override_destination = _config.Inbound.First().RouteOnly ? false : _config.Inbound.First().SniffingEnabled;
|
||||||
inbound.domain_strategy = Utils.IsNullOrEmpty(_config.RoutingBasicItem.DomainStrategy4Singbox) ? null : _config.RoutingBasicItem.DomainStrategy4Singbox;
|
inbound.domain_strategy = _config.RoutingBasicItem.DomainStrategy4Singbox.IsNullOrEmpty() ? null : _config.RoutingBasicItem.DomainStrategy4Singbox;
|
||||||
|
|
||||||
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
||||||
if (routing.DomainStrategy4Singbox.IsNotEmpty())
|
if (routing.DomainStrategy4Singbox.IsNotEmpty())
|
||||||
|
@ -601,7 +601,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
{
|
{
|
||||||
_config.TunModeItem.Mtu = Global.TunMtus.First();
|
_config.TunModeItem.Mtu = Global.TunMtus.First();
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(_config.TunModeItem.Stack))
|
if (_config.TunModeItem.Stack.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
_config.TunModeItem.Stack = Global.TunStacks.First();
|
_config.TunModeItem.Stack = Global.TunStacks.First();
|
||||||
}
|
}
|
||||||
|
@ -698,7 +698,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
|
|
||||||
outbound.packet_encoding = "xudp";
|
outbound.packet_encoding = "xudp";
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(node.Flow))
|
if (node.Flow.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
await GenOutboundMux(node, outbound);
|
await GenOutboundMux(node, outbound);
|
||||||
}
|
}
|
||||||
|
@ -854,8 +854,8 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
{
|
{
|
||||||
case nameof(ETransport.h2):
|
case nameof(ETransport.h2):
|
||||||
transport.type = nameof(ETransport.http);
|
transport.type = nameof(ETransport.http);
|
||||||
transport.host = Utils.IsNullOrEmpty(node.RequestHost) ? null : Utils.String2List(node.RequestHost);
|
transport.host = node.RequestHost.IsNullOrEmpty() ? null : Utils.String2List(node.RequestHost);
|
||||||
transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path;
|
transport.path = node.Path.IsNullOrEmpty() ? null : node.Path;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.tcp): //http
|
case nameof(ETransport.tcp): //http
|
||||||
|
@ -869,15 +869,15 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
transport.type = nameof(ETransport.http);
|
transport.type = nameof(ETransport.http);
|
||||||
transport.host = Utils.IsNullOrEmpty(node.RequestHost) ? null : Utils.String2List(node.RequestHost);
|
transport.host = node.RequestHost.IsNullOrEmpty() ? null : Utils.String2List(node.RequestHost);
|
||||||
transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path;
|
transport.path = node.Path.IsNullOrEmpty() ? null : node.Path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
transport.type = nameof(ETransport.ws);
|
transport.type = nameof(ETransport.ws);
|
||||||
transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path;
|
transport.path = node.Path.IsNullOrEmpty() ? null : node.Path;
|
||||||
if (node.RequestHost.IsNotEmpty())
|
if (node.RequestHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
transport.headers = new()
|
transport.headers = new()
|
||||||
|
@ -889,8 +889,8 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
|
|
||||||
case nameof(ETransport.httpupgrade):
|
case nameof(ETransport.httpupgrade):
|
||||||
transport.type = nameof(ETransport.httpupgrade);
|
transport.type = nameof(ETransport.httpupgrade);
|
||||||
transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path;
|
transport.path = node.Path.IsNullOrEmpty() ? null : node.Path;
|
||||||
transport.host = Utils.IsNullOrEmpty(node.RequestHost) ? null : node.RequestHost;
|
transport.host = node.RequestHost.IsNullOrEmpty() ? null : node.RequestHost;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1241,11 +1241,11 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
var strDNS = string.Empty;
|
var strDNS = string.Empty;
|
||||||
if (_config.TunModeItem.EnableTun)
|
if (_config.TunModeItem.EnableTun)
|
||||||
{
|
{
|
||||||
strDNS = Utils.IsNullOrEmpty(item?.TunDNS) ? EmbedUtils.GetEmbedText(Global.TunSingboxDNSFileName) : item?.TunDNS;
|
strDNS = string.IsNullOrEmpty(item?.TunDNS) ? EmbedUtils.GetEmbedText(Global.TunSingboxDNSFileName) : item?.TunDNS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strDNS = Utils.IsNullOrEmpty(item?.NormalDNS) ? EmbedUtils.GetEmbedText(Global.DNSSingboxNormalFileName) : item?.NormalDNS;
|
strDNS = string.IsNullOrEmpty(item?.NormalDNS) ? EmbedUtils.GetEmbedText(Global.DNSSingboxNormalFileName) : item?.NormalDNS;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dns4Sbox = JsonUtils.Deserialize<Dns4Sbox>(strDNS);
|
var dns4Sbox = JsonUtils.Deserialize<Dns4Sbox>(strDNS);
|
||||||
|
@ -1274,9 +1274,9 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
dns4Sbox.servers.Add(new()
|
dns4Sbox.servers.Add(new()
|
||||||
{
|
{
|
||||||
tag = tag,
|
tag = tag,
|
||||||
address = Utils.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.SingboxDomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress,
|
address = string.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.SingboxDomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress,
|
||||||
detour = Global.DirectTag,
|
detour = Global.DirectTag,
|
||||||
strategy = Utils.IsNullOrEmpty(dNSItem?.DomainStrategy4Freedom) ? null : dNSItem?.DomainStrategy4Freedom,
|
strategy = string.IsNullOrEmpty(dNSItem?.DomainStrategy4Freedom) ? null : dNSItem?.DomainStrategy4Freedom,
|
||||||
});
|
});
|
||||||
dns4Sbox.rules.Insert(0, new()
|
dns4Sbox.rules.Insert(0, new()
|
||||||
{
|
{
|
||||||
|
@ -1414,7 +1414,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
singboxConfig.route.rule_set = [];
|
singboxConfig.route.rule_set = [];
|
||||||
foreach (var item in new HashSet<string>(ruleSets))
|
foreach (var item in new HashSet<string>(ruleSets))
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(item))
|
if (item.IsNullOrEmpty())
|
||||||
{ continue; }
|
{ continue; }
|
||||||
var customRuleset = customRulesets.FirstOrDefault(t => t.tag != null && t.tag.Equals(item));
|
var customRuleset = customRulesets.FirstOrDefault(t => t.tag != null && t.tag.Equals(item));
|
||||||
if (customRuleset is null)
|
if (customRuleset is null)
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
ret.Msg = ResUI.InitialConfiguration;
|
ret.Msg = ResUI.InitialConfiguration;
|
||||||
|
|
||||||
var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -93,7 +93,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
|
|
||||||
string result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
string result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
||||||
string txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
|
string txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
|
||||||
if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
|
if (result.IsNullOrEmpty() || txtOutbound.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -135,7 +135,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id))
|
if (item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
|
|
||||||
var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
||||||
var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
|
var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
|
||||||
if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
|
if (result.IsNullOrEmpty() || txtOutbound.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -261,7 +261,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
|
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
|
||||||
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
||||||
{
|
{
|
||||||
if (item is null || Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id))
|
if (item is null || item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -487,7 +487,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
private Inbounds4Ray GetInbound(InItem inItem, EInboundProtocol protocol, bool bSocks)
|
private Inbounds4Ray GetInbound(InItem inItem, EInboundProtocol protocol, bool bSocks)
|
||||||
{
|
{
|
||||||
string result = EmbedUtils.GetEmbedText(Global.V2raySampleInbound);
|
string result = EmbedUtils.GetEmbedText(Global.V2raySampleInbound);
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
if (v2rayConfig.routing?.rules != null)
|
if (v2rayConfig.routing?.rules != null)
|
||||||
{
|
{
|
||||||
v2rayConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy;
|
v2rayConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy;
|
||||||
v2rayConfig.routing.domainMatcher = Utils.IsNullOrEmpty(_config.RoutingBasicItem.DomainMatcher) ? null : _config.RoutingBasicItem.DomainMatcher;
|
v2rayConfig.routing.domainMatcher = _config.RoutingBasicItem.DomainMatcher.IsNullOrEmpty() ? null : _config.RoutingBasicItem.DomainMatcher;
|
||||||
|
|
||||||
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
||||||
if (routing != null)
|
if (routing != null)
|
||||||
|
@ -551,11 +551,11 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(rule.port))
|
if (rule.port.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
rule.port = null;
|
rule.port = null;
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(rule.network))
|
if (rule.network.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
rule.network = null;
|
rule.network = null;
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1027,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
case nameof(ETransport.grpc):
|
case nameof(ETransport.grpc):
|
||||||
GrpcSettings4Ray grpcSettings = new()
|
GrpcSettings4Ray grpcSettings = new()
|
||||||
{
|
{
|
||||||
authority = Utils.IsNullOrEmpty(host) ? null : host,
|
authority = host.IsNullOrEmpty() ? null : host,
|
||||||
serviceName = path,
|
serviceName = path,
|
||||||
multiMode = node.HeaderType == Global.GrpcMultiMode,
|
multiMode = node.HeaderType == Global.GrpcMultiMode,
|
||||||
idle_timeout = _config.GrpcItem.IdleTimeout,
|
idle_timeout = _config.GrpcItem.IdleTimeout,
|
||||||
|
@ -1085,7 +1085,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
|
var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
|
||||||
var normalDNS = item?.NormalDNS;
|
var normalDNS = item?.NormalDNS;
|
||||||
var domainStrategy4Freedom = item?.DomainStrategy4Freedom;
|
var domainStrategy4Freedom = item?.DomainStrategy4Freedom;
|
||||||
if (Utils.IsNullOrEmpty(normalDNS))
|
if (normalDNS.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
normalDNS = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
normalDNS = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
||||||
}
|
}
|
||||||
|
@ -1156,7 +1156,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
{
|
{
|
||||||
var dnsServer = new DnsServer4Ray()
|
var dnsServer = new DnsServer4Ray()
|
||||||
{
|
{
|
||||||
address = Utils.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress,
|
address = string.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress,
|
||||||
domains = [node.Address]
|
domains = [node.Address]
|
||||||
};
|
};
|
||||||
servers.AsArray().Add(JsonUtils.SerializeToNode(dnsServer));
|
servers.AsArray().Add(JsonUtils.SerializeToNode(dnsServer));
|
||||||
|
|
|
@ -160,7 +160,7 @@ namespace ServiceLib.Services
|
||||||
UseProxy = webProxy != null
|
UseProxy = webProxy != null
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(userAgent))
|
if (userAgent.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
userAgent = Utils.GetVersion(false);
|
userAgent = Utils.GetVersion(false);
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ namespace ServiceLib.Services
|
||||||
|
|
||||||
var webProxy = await GetWebProxy(blProxy);
|
var webProxy = await GetWebProxy(blProxy);
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(userAgent))
|
if (userAgent.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
userAgent = Utils.GetVersion(false);
|
userAgent = Utils.GetVersion(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace ServiceLib.Services
|
||||||
var url = item.Url.TrimEx();
|
var url = item.Url.TrimEx();
|
||||||
var userAgent = item.UserAgent.TrimEx();
|
var userAgent = item.UserAgent.TrimEx();
|
||||||
var hashCode = $"{item.Remarks}->";
|
var hashCode = $"{item.Remarks}->";
|
||||||
if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url) || (subId.IsNotEmpty() && item.Id != subId))
|
if (id.IsNullOrEmpty() || url.IsNullOrEmpty() || (subId.IsNotEmpty() && item.Id != subId))
|
||||||
{
|
{
|
||||||
//_updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
|
//_updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
|
||||||
continue;
|
continue;
|
||||||
|
@ -151,7 +151,7 @@ namespace ServiceLib.Services
|
||||||
//convert
|
//convert
|
||||||
if (item.ConvertTarget.IsNotEmpty())
|
if (item.ConvertTarget.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var subConvertUrl = Utils.IsNullOrEmpty(config.ConstItem.SubConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.ConstItem.SubConvertUrl;
|
var subConvertUrl = config.ConstItem.SubConvertUrl.IsNullOrEmpty() ? Global.SubConvertUrls.FirstOrDefault() : config.ConstItem.SubConvertUrl;
|
||||||
url = string.Format(subConvertUrl!, Utils.UrlEncode(url));
|
url = string.Format(subConvertUrl!, Utils.UrlEncode(url));
|
||||||
if (!url.Contains("target="))
|
if (!url.Contains("target="))
|
||||||
{
|
{
|
||||||
|
@ -163,13 +163,13 @@ namespace ServiceLib.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var result = await downloadHandle.TryDownloadString(url, blProxy, userAgent);
|
var result = await downloadHandle.TryDownloadString(url, blProxy, userAgent);
|
||||||
if (blProxy && Utils.IsNullOrEmpty(result))
|
if (blProxy && result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
result = await downloadHandle.TryDownloadString(url, false, userAgent);
|
result = await downloadHandle.TryDownloadString(url, false, userAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
//more url
|
//more url
|
||||||
if (Utils.IsNullOrEmpty(item.ConvertTarget) && item.MoreUrl.TrimEx().IsNotEmpty())
|
if (item.ConvertTarget.IsNullOrEmpty() && item.MoreUrl.TrimEx().IsNotEmpty())
|
||||||
{
|
{
|
||||||
if (result.IsNotEmpty() && Utils.IsBase64String(result))
|
if (result.IsNotEmpty() && Utils.IsBase64String(result))
|
||||||
{
|
{
|
||||||
|
@ -180,13 +180,13 @@ namespace ServiceLib.Services
|
||||||
foreach (var it in lstUrl)
|
foreach (var it in lstUrl)
|
||||||
{
|
{
|
||||||
var url2 = Utils.GetPunycode(it);
|
var url2 = Utils.GetPunycode(it);
|
||||||
if (Utils.IsNullOrEmpty(url2))
|
if (url2.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result2 = await downloadHandle.TryDownloadString(url2, blProxy, userAgent);
|
var result2 = await downloadHandle.TryDownloadString(url2, blProxy, userAgent);
|
||||||
if (blProxy && Utils.IsNullOrEmpty(result2))
|
if (blProxy && result2.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
result2 = await downloadHandle.TryDownloadString(url2, false, userAgent);
|
result2 = await downloadHandle.TryDownloadString(url2, false, userAgent);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ namespace ServiceLib.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
_updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgSubscriptionDecodingFailed}");
|
_updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgSubscriptionDecodingFailed}");
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ namespace ServiceLib.Services
|
||||||
{
|
{
|
||||||
var url = coreInfo?.ReleaseApiUrl;
|
var url = coreInfo?.ReleaseApiUrl;
|
||||||
var result = await downloadHandle.TryDownloadString(url, true, Global.AppName);
|
var result = await downloadHandle.TryDownloadString(url, true, Global.AppName);
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return new RetResult(false, "");
|
return new RetResult(false, "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,13 +43,13 @@ namespace ServiceLib.ViewModels
|
||||||
private async Task SaveServerAsync()
|
private async Task SaveServerAsync()
|
||||||
{
|
{
|
||||||
string remarks = SelectedSource.Remarks;
|
string remarks = SelectedSource.Remarks;
|
||||||
if (Utils.IsNullOrEmpty(remarks))
|
if (remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(SelectedSource.Address))
|
if (SelectedSource.Address.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
||||||
return;
|
return;
|
||||||
|
@ -69,7 +69,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public async Task BrowseServer(string fileName)
|
public async Task BrowseServer(string fileName)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ namespace ServiceLib.ViewModels
|
||||||
private async Task EditServer()
|
private async Task EditServer()
|
||||||
{
|
{
|
||||||
var address = SelectedSource.Address;
|
var address = SelectedSource.Address;
|
||||||
if (Utils.IsNullOrEmpty(address))
|
if (address.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -41,19 +41,19 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private async Task SaveServerAsync()
|
private async Task SaveServerAsync()
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(SelectedSource.Remarks))
|
if (SelectedSource.Remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(SelectedSource.Address))
|
if (SelectedSource.Address.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddress);
|
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddress);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var port = SelectedSource.Port.ToString();
|
var port = SelectedSource.Port.ToString();
|
||||||
if (Utils.IsNullOrEmpty(port) || !Utils.IsNumeric(port)
|
if (port.IsNullOrEmpty() || !Utils.IsNumeric(port)
|
||||||
|| SelectedSource.Port <= 0 || SelectedSource.Port >= Global.MaxPort)
|
|| SelectedSource.Port <= 0 || SelectedSource.Port >= Global.MaxPort)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectServerPort);
|
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectServerPort);
|
||||||
|
@ -61,12 +61,12 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
if (SelectedSource.ConfigType == EConfigType.Shadowsocks)
|
if (SelectedSource.ConfigType == EConfigType.Shadowsocks)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(SelectedSource.Id))
|
if (SelectedSource.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillPassword);
|
NoticeHandler.Instance.Enqueue(ResUI.FillPassword);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(SelectedSource.Security))
|
if (SelectedSource.Security.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectEncryption);
|
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectEncryption);
|
||||||
return;
|
return;
|
||||||
|
@ -75,7 +75,7 @@ namespace ServiceLib.ViewModels
|
||||||
if (SelectedSource.ConfigType != EConfigType.SOCKS
|
if (SelectedSource.ConfigType != EConfigType.SOCKS
|
||||||
&& SelectedSource.ConfigType != EConfigType.HTTP)
|
&& SelectedSource.ConfigType != EConfigType.HTTP)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(SelectedSource.Id))
|
if (SelectedSource.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillUUID);
|
NoticeHandler.Instance.Enqueue(ResUI.FillUUID);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -114,7 +114,7 @@ namespace ServiceLib.ViewModels
|
||||||
public async Task LocalRestore(string fileName)
|
public async Task LocalRestore(string fileName)
|
||||||
{
|
{
|
||||||
DisplayOperationMsg();
|
DisplayOperationMsg();
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private async Task<bool> CreateZipFileFromDirectory(string fileName)
|
private async Task<bool> CreateZipFileFromDirectory(string fileName)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace ServiceLib.ViewModels
|
||||||
var lstModel = new List<ClashConnectionModel>();
|
var lstModel = new List<ClashConnectionModel>();
|
||||||
foreach (var item in connections ?? new())
|
foreach (var item in connections ?? new())
|
||||||
{
|
{
|
||||||
var host = $"{(Utils.IsNullOrEmpty(item.metadata.host) ? item.metadata.destinationIP : item.metadata.host)}:{item.metadata.destinationPort}";
|
var host = $"{(item.metadata.host.IsNullOrEmpty() ? item.metadata.destinationIP : item.metadata.host)}:{item.metadata.destinationPort}";
|
||||||
if (HostFilter.IsNotEmpty() && !host.Contains(HostFilter))
|
if (HostFilter.IsNotEmpty() && !host.Contains(HostFilter))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -193,7 +193,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
foreach (var it in proxyGroups)
|
foreach (var it in proxyGroups)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(it.name) || !_proxies.ContainsKey(it.name))
|
if (it.name.IsNullOrEmpty() || !_proxies.ContainsKey(it.name))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var name = SelectedGroup?.Name;
|
var name = SelectedGroup?.Name;
|
||||||
if (Utils.IsNullOrEmpty(name))
|
if (name.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -341,21 +341,21 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public async Task SetActiveProxy()
|
public async Task SetActiveProxy()
|
||||||
{
|
{
|
||||||
if (SelectedGroup == null || Utils.IsNullOrEmpty(SelectedGroup.Name))
|
if (SelectedGroup == null || SelectedGroup.Name.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (SelectedDetail == null || Utils.IsNullOrEmpty(SelectedDetail.Name))
|
if (SelectedDetail == null || SelectedDetail.Name.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var name = SelectedGroup.Name;
|
var name = SelectedGroup.Name;
|
||||||
if (Utils.IsNullOrEmpty(name))
|
if (name.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var nameNode = SelectedDetail.Name;
|
var nameNode = SelectedDetail.Name;
|
||||||
if (Utils.IsNullOrEmpty(nameNode))
|
if (nameNode.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ namespace ServiceLib.ViewModels
|
||||||
await GetClashProxies(true);
|
await GetClashProxies(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,7 +421,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public async Task ScanImageResult(string fileName)
|
public async Task ScanImageResult(string fileName)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private async Task AddScanResultAsync(string? result)
|
private async Task AddScanResultAsync(string? result)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.NoValidQRcodeFound);
|
NoticeHandler.Instance.Enqueue(ResUI.NoValidQRcodeFound);
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private async Task SaveSettingAsync()
|
private async Task SaveSettingAsync()
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(localPort.ToString()) || !Utils.IsNumeric(localPort.ToString())
|
if (localPort.ToString().IsNullOrEmpty() || !Utils.IsNumeric(localPort.ToString())
|
||||||
|| localPort <= 0 || localPort >= Global.MaxPort)
|
|| localPort <= 0 || localPort >= Global.MaxPort)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort);
|
NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort);
|
||||||
|
|
|
@ -267,7 +267,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public void SetSpeedTestResult(SpeedTestResult result)
|
public void SetSpeedTestResult(SpeedTestResult result)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(result.IndexId))
|
if (result.IndexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.SendMessageEx(result.Delay);
|
NoticeHandler.Instance.SendMessageEx(result.Delay);
|
||||||
NoticeHandler.Instance.Enqueue(result.Delay);
|
NoticeHandler.Instance.Enqueue(result.Delay);
|
||||||
|
@ -350,7 +350,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_serverFilter = ServerFilter;
|
_serverFilter = ServerFilter;
|
||||||
if (Utils.IsNullOrEmpty(_serverFilter))
|
if (_serverFilter.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public async Task EditServerAsync(EConfigType eConfigType)
|
public async Task EditServerAsync(EConfigType eConfigType)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(SelectedProfile?.IndexId))
|
if (string.IsNullOrEmpty(SelectedProfile?.IndexId))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -557,7 +557,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public async Task SetDefaultServer()
|
public async Task SetDefaultServer()
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(SelectedProfile?.IndexId))
|
if (string.IsNullOrEmpty(SelectedProfile?.IndexId))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -566,7 +566,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public async Task SetDefaultServer(string indexId)
|
public async Task SetDefaultServer(string indexId)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(indexId))
|
if (indexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(SelectedServer.ID))
|
if (SelectedServer.ID.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -614,7 +614,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var url = FmtHandler.GetShareUri(item);
|
var url = FmtHandler.GetShareUri(item);
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -649,7 +649,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public async Task SortServer(string colName)
|
public async Task SortServer(string colName)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(colName))
|
if (colName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -776,7 +776,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public async Task Export2ClientConfigResult(string fileName, ProfileItem item)
|
public async Task Export2ClientConfigResult(string fileName, ProfileItem item)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -803,7 +803,7 @@ namespace ServiceLib.ViewModels
|
||||||
foreach (var it in lstSelecteds)
|
foreach (var it in lstSelecteds)
|
||||||
{
|
{
|
||||||
var url = FmtHandler.GetShareUri(it);
|
var url = FmtHandler.GetShareUri(it);
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,7 +224,7 @@ namespace ServiceLib.ViewModels
|
||||||
private async Task SaveRoutingAsync()
|
private async Task SaveRoutingAsync()
|
||||||
{
|
{
|
||||||
string remarks = SelectedRouting.Remarks;
|
string remarks = SelectedRouting.Remarks;
|
||||||
if (Utils.IsNullOrEmpty(remarks))
|
if (remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||||
return;
|
return;
|
||||||
|
@ -252,13 +252,13 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public async Task ImportRulesFromFileAsync(string fileName)
|
public async Task ImportRulesFromFileAsync(string fileName)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = EmbedUtils.LoadResource(fileName);
|
var result = EmbedUtils.LoadResource(fileName);
|
||||||
if (Utils.IsNullOrEmpty(result))
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ namespace ServiceLib.ViewModels
|
||||||
private async Task ImportRulesFromUrl()
|
private async Task ImportRulesFromUrl()
|
||||||
{
|
{
|
||||||
var url = SelectedRouting.Url;
|
var url = SelectedRouting.Url;
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.MsgNeedUrl);
|
NoticeHandler.Instance.Enqueue(ResUI.MsgNeedUrl);
|
||||||
return;
|
return;
|
||||||
|
@ -311,7 +311,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
blReplace = true;
|
blReplace = true;
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(clipboardData))
|
if (clipboardData.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Utils.IsNullOrEmpty(SelectedServer.ID))
|
if (SelectedServer.ID.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace ServiceLib.ViewModels
|
||||||
private async Task SaveSubAsync()
|
private async Task SaveSubAsync()
|
||||||
{
|
{
|
||||||
var remarks = SelectedSource.Remarks;
|
var remarks = SelectedSource.Remarks;
|
||||||
if (Utils.IsNullOrEmpty(remarks))
|
if (remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -272,7 +272,7 @@ namespace v2rayN.Desktop.Views
|
||||||
cmbHeaderType.Items.Clear();
|
cmbHeaderType.Items.Clear();
|
||||||
|
|
||||||
var network = cmbNetwork.SelectedItem.ToString();
|
var network = cmbNetwork.SelectedItem.ToString();
|
||||||
if (Utils.IsNullOrEmpty(network))
|
if (network.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
cmbHeaderType.Items.Add(Global.None);
|
cmbHeaderType.Items.Add(Global.None);
|
||||||
return;
|
return;
|
||||||
|
@ -313,7 +313,7 @@ namespace v2rayN.Desktop.Views
|
||||||
private void SetTips()
|
private void SetTips()
|
||||||
{
|
{
|
||||||
var network = cmbNetwork.SelectedItem.ToString();
|
var network = cmbNetwork.SelectedItem.ToString();
|
||||||
if (Utils.IsNullOrEmpty(network))
|
if (network.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
network = Global.DefaultNetwork;
|
network = Global.DefaultNetwork;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ namespace v2rayN.Desktop.Views
|
||||||
|
|
||||||
public async Task ShareServer(string url)
|
public async Task ShareServer(string url)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace v2rayN.Desktop.Views
|
||||||
|
|
||||||
private async Task ShareSub(string url)
|
private async Task ShareSub(string url)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace v2rayN.Handler
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = await ConfigHandler.GetDefaultRouting(config);
|
var item = await ConfigHandler.GetDefaultRouting(config);
|
||||||
if (item == null || Utils.IsNullOrEmpty(item.CustomIcon) || !File.Exists(item.CustomIcon))
|
if (item == null || item.CustomIcon.IsNullOrEmpty() || !File.Exists(item.CustomIcon))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ namespace v2rayN.Views
|
||||||
cmbHeaderType.Items.Clear();
|
cmbHeaderType.Items.Clear();
|
||||||
|
|
||||||
var network = cmbNetwork.SelectedItem.ToString();
|
var network = cmbNetwork.SelectedItem.ToString();
|
||||||
if (Utils.IsNullOrEmpty(network))
|
if (network.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
cmbHeaderType.Items.Add(Global.None);
|
cmbHeaderType.Items.Add(Global.None);
|
||||||
return;
|
return;
|
||||||
|
@ -308,7 +308,7 @@ namespace v2rayN.Views
|
||||||
private void SetTips()
|
private void SetTips()
|
||||||
{
|
{
|
||||||
var network = cmbNetwork.SelectedItem.ToString();
|
var network = cmbNetwork.SelectedItem.ToString();
|
||||||
if (Utils.IsNullOrEmpty(network))
|
if (network.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
network = Global.DefaultNetwork;
|
network = Global.DefaultNetwork;
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,10 +234,10 @@ namespace v2rayN.Views
|
||||||
// continue;
|
// continue;
|
||||||
//}
|
//}
|
||||||
var fontFamily = glyph.Win32FamilyNames[new CultureInfo(culture)];
|
var fontFamily = glyph.Win32FamilyNames[new CultureInfo(culture)];
|
||||||
if (Utils.IsNullOrEmpty(fontFamily))
|
if (fontFamily.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
fontFamily = glyph.Win32FamilyNames[new CultureInfo(culture2)];
|
fontFamily = glyph.Win32FamilyNames[new CultureInfo(culture2)];
|
||||||
if (Utils.IsNullOrEmpty(fontFamily))
|
if (fontFamily.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
private async void ShareSub(string url)
|
private async void ShareSub(string url)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue