mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 13:42:24 +00:00
Replace all Utils.IsNotEmpty(variable) with variable.IsNotEmpty()
This commit is contained in:
parent
78fde575d7
commit
f3af831cf2
33 changed files with 128 additions and 133 deletions
|
@ -18,7 +18,7 @@ namespace ServiceLib.Common
|
||||||
Uri uri = new(url);
|
Uri uri = new(url);
|
||||||
//Authorization Header
|
//Authorization Header
|
||||||
var headers = new WebHeaderCollection();
|
var headers = new WebHeaderCollection();
|
||||||
if (Utils.IsNotEmpty(uri.UserInfo))
|
if (uri.UserInfo.IsNotEmpty())
|
||||||
{
|
{
|
||||||
headers.Add(HttpRequestHeader.Authorization, "Basic " + Utils.Base64Encode(uri.UserInfo));
|
headers.Add(HttpRequestHeader.Authorization, "Basic " + Utils.Base64Encode(uri.UserInfo));
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ namespace ServiceLib.Common
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(ignoredName) && entry.Name.Contains(ignoredName))
|
if (ignoredName.IsNotEmpty() && entry.Name.Contains(ignoredName))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ namespace ServiceLib.Common
|
||||||
// Get the files in the source directory and copy to the destination directory
|
// Get the files in the source directory and copy to the destination directory
|
||||||
foreach (var file in dir.GetFiles())
|
foreach (var file in dir.GetFiles())
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(ignoredName) && file.Name.Contains(ignoredName))
|
if (ignoredName.IsNotEmpty() && file.Name.Contains(ignoredName))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace ServiceLib.Common
|
||||||
var reader = new BarcodeReader();
|
var reader = new BarcodeReader();
|
||||||
var result = reader.Decode(bitmap);
|
var result = reader.Decode(bitmap);
|
||||||
|
|
||||||
if (result != null && Utils.IsNotEmpty(result.Text))
|
if (result != null && result.Text.IsNotEmpty())
|
||||||
{
|
{
|
||||||
return result.Text;
|
return result.Text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace ServiceLib.Common
|
||||||
{
|
{
|
||||||
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? value)
|
public static bool IsNullOrEmpty([NotNullWhen(false)] this string? value)
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(value);
|
return string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsNullOrWhiteSpace([NotNullWhen(false)] this string? value)
|
public static bool IsNullOrWhiteSpace([NotNullWhen(false)] this string? value)
|
||||||
|
|
|
@ -363,11 +363,6 @@ namespace ServiceLib.Common
|
||||||
return text == "null";
|
return text == "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsNotEmpty(string? text)
|
|
||||||
{
|
|
||||||
return !string.IsNullOrEmpty(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证Domain地址是否合法
|
/// 验证Domain地址是否合法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -153,11 +153,11 @@ namespace ServiceLib.Handler
|
||||||
from ProfileItem a
|
from ProfileItem a
|
||||||
left join SubItem b on a.subid = b.id
|
left join SubItem b on a.subid = b.id
|
||||||
where 1=1 ";
|
where 1=1 ";
|
||||||
if (Utils.IsNotEmpty(subid))
|
if (subid.IsNotEmpty())
|
||||||
{
|
{
|
||||||
sql += $" and a.subid = '{subid}'";
|
sql += $" and a.subid = '{subid}'";
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(filter))
|
if (filter.IsNotEmpty())
|
||||||
{
|
{
|
||||||
if (filter.Contains('\''))
|
if (filter.Contains('\''))
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
Config? config = null;
|
Config? config = null;
|
||||||
var result = EmbedUtils.LoadResource(Utils.GetConfigPath(_configRes));
|
var result = EmbedUtils.LoadResource(Utils.GetConfigPath(_configRes));
|
||||||
if (Utils.IsNotEmpty(result))
|
if (result.IsNotEmpty())
|
||||||
{
|
{
|
||||||
config = JsonUtils.Deserialize<Config>(result);
|
config = JsonUtils.Deserialize<Config>(result);
|
||||||
}
|
}
|
||||||
|
@ -858,7 +858,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(profileItem.Security) && profileItem.Security != Global.None)
|
if (profileItem.Security.IsNotEmpty() && profileItem.Security != Global.None)
|
||||||
{
|
{
|
||||||
profileItem.Security = Global.None;
|
profileItem.Security = Global.None;
|
||||||
}
|
}
|
||||||
|
@ -897,7 +897,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
profileItem.ConfigVersion = 2;
|
profileItem.ConfigVersion = 2;
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(profileItem.StreamSecurity))
|
if (profileItem.StreamSecurity.IsNotEmpty())
|
||||||
{
|
{
|
||||||
if (profileItem.StreamSecurity != Global.StreamSecurity
|
if (profileItem.StreamSecurity != Global.StreamSecurity
|
||||||
&& profileItem.StreamSecurity != Global.StreamSecurityReality)
|
&& profileItem.StreamSecurity != Global.StreamSecurityReality)
|
||||||
|
@ -917,7 +917,7 @@ namespace ServiceLib.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(profileItem.Network) && !Global.Networks.Contains(profileItem.Network))
|
if (profileItem.Network.IsNotEmpty() && !Global.Networks.Contains(profileItem.Network))
|
||||||
{
|
{
|
||||||
profileItem.Network = Global.DefaultNetwork;
|
profileItem.Network = Global.DefaultNetwork;
|
||||||
}
|
}
|
||||||
|
@ -1091,7 +1091,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
var subFilter = string.Empty;
|
var subFilter = string.Empty;
|
||||||
//remove sub items
|
//remove sub items
|
||||||
if (isSub && Utils.IsNotEmpty(subid))
|
if (isSub && subid.IsNotEmpty())
|
||||||
{
|
{
|
||||||
await RemoveServersViaSubid(config, subid, isSub);
|
await RemoveServersViaSubid(config, subid, isSub);
|
||||||
subFilter = (await AppHandler.Instance.GetSubItem(subid))?.Filter ?? "";
|
subFilter = (await AppHandler.Instance.GetSubItem(subid))?.Filter ?? "";
|
||||||
|
@ -1122,7 +1122,7 @@ namespace ServiceLib.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
//exist sub items //filter
|
//exist sub items //filter
|
||||||
if (isSub && Utils.IsNotEmpty(subid) && Utils.IsNotEmpty(subFilter))
|
if (isSub && subid.IsNotEmpty() && subFilter.IsNotEmpty())
|
||||||
{
|
{
|
||||||
if (!Regex.IsMatch(profileItem.Remarks, subFilter))
|
if (!Regex.IsMatch(profileItem.Remarks, subFilter))
|
||||||
{
|
{
|
||||||
|
@ -1185,7 +1185,7 @@ namespace ServiceLib.Handler
|
||||||
}
|
}
|
||||||
if (lstProfiles != null && lstProfiles.Count > 0)
|
if (lstProfiles != null && lstProfiles.Count > 0)
|
||||||
{
|
{
|
||||||
if (isSub && Utils.IsNotEmpty(subid))
|
if (isSub && subid.IsNotEmpty())
|
||||||
{
|
{
|
||||||
await RemoveServersViaSubid(config, subid, isSub);
|
await RemoveServersViaSubid(config, subid, isSub);
|
||||||
}
|
}
|
||||||
|
@ -1241,7 +1241,7 @@ namespace ServiceLib.Handler
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSub && Utils.IsNotEmpty(subid))
|
if (isSub && subid.IsNotEmpty())
|
||||||
{
|
{
|
||||||
await RemoveServersViaSubid(config, subid, isSub);
|
await RemoveServersViaSubid(config, subid, isSub);
|
||||||
}
|
}
|
||||||
|
@ -1266,7 +1266,7 @@ namespace ServiceLib.Handler
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSub && Utils.IsNotEmpty(subid))
|
if (isSub && subid.IsNotEmpty())
|
||||||
{
|
{
|
||||||
await RemoveServersViaSubid(config, subid, isSub);
|
await RemoveServersViaSubid(config, subid, isSub);
|
||||||
}
|
}
|
||||||
|
@ -1299,7 +1299,7 @@ namespace ServiceLib.Handler
|
||||||
}
|
}
|
||||||
List<ProfileItem>? lstOriSub = null;
|
List<ProfileItem>? lstOriSub = null;
|
||||||
ProfileItem? activeProfile = null;
|
ProfileItem? activeProfile = null;
|
||||||
if (isSub && Utils.IsNotEmpty(subid))
|
if (isSub && subid.IsNotEmpty())
|
||||||
{
|
{
|
||||||
lstOriSub = await AppHandler.Instance.ProfileItems(subid);
|
lstOriSub = await AppHandler.Instance.ProfileItems(subid);
|
||||||
activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == config.IndexId);
|
activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == config.IndexId);
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(fileName) && result.Data != null)
|
if (fileName.IsNotEmpty() && result.Data != null)
|
||||||
{
|
{
|
||||||
await File.WriteAllTextAsync(fileName, result.Data.ToString());
|
await File.WriteAllTextAsync(fileName, result.Data.ToString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@ namespace ServiceLib.Handler.Fmt
|
||||||
|
|
||||||
protected static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
protected static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(item.Flow))
|
if (item.Flow.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("flow", item.Flow);
|
dicQuery.Add("flow", item.Flow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(item.StreamSecurity))
|
if (item.StreamSecurity.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("security", item.StreamSecurity);
|
dicQuery.Add("security", item.StreamSecurity);
|
||||||
}
|
}
|
||||||
|
@ -32,27 +32,27 @@ namespace ServiceLib.Handler.Fmt
|
||||||
dicQuery.Add("security", securityDef);
|
dicQuery.Add("security", securityDef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Sni))
|
if (item.Sni.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("sni", item.Sni);
|
dicQuery.Add("sni", item.Sni);
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Alpn))
|
if (item.Alpn.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Fingerprint))
|
if (item.Fingerprint.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("fp", Utils.UrlEncode(item.Fingerprint));
|
dicQuery.Add("fp", Utils.UrlEncode(item.Fingerprint));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.PublicKey))
|
if (item.PublicKey.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("pbk", Utils.UrlEncode(item.PublicKey));
|
dicQuery.Add("pbk", Utils.UrlEncode(item.PublicKey));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.ShortId))
|
if (item.ShortId.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("sid", Utils.UrlEncode(item.ShortId));
|
dicQuery.Add("sid", Utils.UrlEncode(item.ShortId));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.SpiderX))
|
if (item.SpiderX.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("spx", Utils.UrlEncode(item.SpiderX));
|
dicQuery.Add("spx", Utils.UrlEncode(item.SpiderX));
|
||||||
}
|
}
|
||||||
|
@ -61,21 +61,21 @@ namespace ServiceLib.Handler.Fmt
|
||||||
dicQuery.Add("allowInsecure", "1");
|
dicQuery.Add("allowInsecure", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
dicQuery.Add("type", Utils.IsNotEmpty(item.Network) ? item.Network : nameof(ETransport.tcp));
|
dicQuery.Add("type", item.Network.IsNotEmpty() ? item.Network : nameof(ETransport.tcp));
|
||||||
|
|
||||||
switch (item.Network)
|
switch (item.Network)
|
||||||
{
|
{
|
||||||
case nameof(ETransport.tcp):
|
case nameof(ETransport.tcp):
|
||||||
dicQuery.Add("headerType", Utils.IsNotEmpty(item.HeaderType) ? item.HeaderType : Global.None);
|
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None);
|
||||||
if (Utils.IsNotEmpty(item.RequestHost))
|
if (item.RequestHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.kcp):
|
case nameof(ETransport.kcp):
|
||||||
dicQuery.Add("headerType", Utils.IsNotEmpty(item.HeaderType) ? item.HeaderType : Global.None);
|
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None);
|
||||||
if (Utils.IsNotEmpty(item.Path))
|
if (item.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("seed", Utils.UrlEncode(item.Path));
|
dicQuery.Add("seed", Utils.UrlEncode(item.Path));
|
||||||
}
|
}
|
||||||
|
@ -83,30 +83,30 @@ namespace ServiceLib.Handler.Fmt
|
||||||
|
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
case nameof(ETransport.httpupgrade):
|
case nameof(ETransport.httpupgrade):
|
||||||
if (Utils.IsNotEmpty(item.RequestHost))
|
if (item.RequestHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Path))
|
if (item.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.xhttp):
|
case nameof(ETransport.xhttp):
|
||||||
if (Utils.IsNotEmpty(item.RequestHost))
|
if (item.RequestHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Path))
|
if (item.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.HeaderType) && Global.XhttpMode.Contains(item.HeaderType))
|
if (item.HeaderType.IsNotEmpty() && Global.XhttpMode.Contains(item.HeaderType))
|
||||||
{
|
{
|
||||||
dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType));
|
dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Extra))
|
if (item.Extra.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("extra", Utils.UrlEncode(item.Extra));
|
dicQuery.Add("extra", Utils.UrlEncode(item.Extra));
|
||||||
}
|
}
|
||||||
|
@ -115,24 +115,24 @@ namespace ServiceLib.Handler.Fmt
|
||||||
case nameof(ETransport.http):
|
case nameof(ETransport.http):
|
||||||
case nameof(ETransport.h2):
|
case nameof(ETransport.h2):
|
||||||
dicQuery["type"] = nameof(ETransport.http);
|
dicQuery["type"] = nameof(ETransport.http);
|
||||||
if (Utils.IsNotEmpty(item.RequestHost))
|
if (item.RequestHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Path))
|
if (item.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.quic):
|
case nameof(ETransport.quic):
|
||||||
dicQuery.Add("headerType", Utils.IsNotEmpty(item.HeaderType) ? item.HeaderType : Global.None);
|
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None);
|
||||||
dicQuery.Add("quicSecurity", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("quicSecurity", Utils.UrlEncode(item.RequestHost));
|
||||||
dicQuery.Add("key", Utils.UrlEncode(item.Path));
|
dicQuery.Add("key", Utils.UrlEncode(item.Path));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nameof(ETransport.grpc):
|
case nameof(ETransport.grpc):
|
||||||
if (Utils.IsNotEmpty(item.Path))
|
if (item.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("authority", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("authority", Utils.UrlEncode(item.RequestHost));
|
||||||
dicQuery.Add("serviceName", Utils.UrlEncode(item.Path));
|
dicQuery.Add("serviceName", Utils.UrlEncode(item.Path));
|
||||||
|
|
|
@ -36,26 +36,26 @@ namespace ServiceLib.Handler.Fmt
|
||||||
string url = string.Empty;
|
string url = string.Empty;
|
||||||
|
|
||||||
string remark = string.Empty;
|
string remark = string.Empty;
|
||||||
if (Utils.IsNotEmpty(item.Remarks))
|
if (item.Remarks.IsNotEmpty())
|
||||||
{
|
{
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
if (Utils.IsNotEmpty(item.Sni))
|
if (item.Sni.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("sni", item.Sni);
|
dicQuery.Add("sni", item.Sni);
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Alpn))
|
if (item.Alpn.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Path))
|
if (item.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("obfs", "salamander");
|
dicQuery.Add("obfs", "salamander");
|
||||||
dicQuery.Add("obfs-password", Utils.UrlEncode(item.Path));
|
dicQuery.Add("obfs-password", Utils.UrlEncode(item.Path));
|
||||||
}
|
}
|
||||||
dicQuery.Add("insecure", item.AllowInsecure.ToLower() == "true" ? "1" : "0");
|
dicQuery.Add("insecure", item.AllowInsecure.ToLower() == "true" ? "1" : "0");
|
||||||
if (Utils.IsNotEmpty(item.Ports))
|
if (item.Ports.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("mport", Utils.UrlEncode(item.Ports.Replace(':', '-')));
|
dicQuery.Add("mport", Utils.UrlEncode(item.Ports.Replace(':', '-')));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace ServiceLib.Handler.Fmt
|
||||||
string url = string.Empty;
|
string url = string.Empty;
|
||||||
|
|
||||||
string remark = string.Empty;
|
string remark = string.Empty;
|
||||||
if (Utils.IsNotEmpty(item.Remarks))
|
if (item.Remarks.IsNotEmpty())
|
||||||
{
|
{
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace ServiceLib.Handler.Fmt
|
||||||
ProfileItem item = new();
|
ProfileItem item = new();
|
||||||
var base64 = match.Groups["base64"].Value.TrimEnd('/');
|
var base64 = match.Groups["base64"].Value.TrimEnd('/');
|
||||||
var tag = match.Groups["tag"].Value;
|
var tag = match.Groups["tag"].Value;
|
||||||
if (Utils.IsNotEmpty(tag))
|
if (tag.IsNotEmpty())
|
||||||
{
|
{
|
||||||
item.Remarks = Utils.UrlDecode(tag);
|
item.Remarks = Utils.UrlDecode(tag);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ namespace ServiceLib.Handler.Fmt
|
||||||
{
|
{
|
||||||
//obfs-host exists
|
//obfs-host exists
|
||||||
var obfsHost = queryParameters["plugin"]?.Split(';').FirstOrDefault(t => t.Contains("obfs-host"));
|
var obfsHost = queryParameters["plugin"]?.Split(';').FirstOrDefault(t => t.Contains("obfs-host"));
|
||||||
if (queryParameters["plugin"].Contains("obfs=http") && Utils.IsNotEmpty(obfsHost))
|
if (queryParameters["plugin"].Contains("obfs=http") && obfsHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
obfsHost = obfsHost?.Replace("obfs-host=", "");
|
obfsHost = obfsHost?.Replace("obfs-host=", "");
|
||||||
item.Network = Global.DefaultNetwork;
|
item.Network = Global.DefaultNetwork;
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace ServiceLib.Handler.Fmt
|
||||||
var url = string.Empty;
|
var url = string.Empty;
|
||||||
|
|
||||||
var remark = string.Empty;
|
var remark = string.Empty;
|
||||||
if (Utils.IsNotEmpty(item.Remarks))
|
if (item.Remarks.IsNotEmpty())
|
||||||
{
|
{
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace ServiceLib.Handler.Fmt
|
||||||
string url = string.Empty;
|
string url = string.Empty;
|
||||||
|
|
||||||
string remark = string.Empty;
|
string remark = string.Empty;
|
||||||
if (Utils.IsNotEmpty(item.Remarks))
|
if (item.Remarks.IsNotEmpty())
|
||||||
{
|
{
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,16 +40,16 @@ namespace ServiceLib.Handler.Fmt
|
||||||
string url = string.Empty;
|
string url = string.Empty;
|
||||||
|
|
||||||
string remark = string.Empty;
|
string remark = string.Empty;
|
||||||
if (Utils.IsNotEmpty(item.Remarks))
|
if (item.Remarks.IsNotEmpty())
|
||||||
{
|
{
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
if (Utils.IsNotEmpty(item.Sni))
|
if (item.Sni.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("sni", item.Sni);
|
dicQuery.Add("sni", item.Sni);
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Alpn))
|
if (item.Alpn.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,12 @@ namespace ServiceLib.Handler.Fmt
|
||||||
string url = string.Empty;
|
string url = string.Empty;
|
||||||
|
|
||||||
string remark = string.Empty;
|
string remark = string.Empty;
|
||||||
if (Utils.IsNotEmpty(item.Remarks))
|
if (item.Remarks.IsNotEmpty())
|
||||||
{
|
{
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
if (Utils.IsNotEmpty(item.Security))
|
if (item.Security.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("encryption", item.Security);
|
dicQuery.Add("encryption", item.Security);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,12 +78,12 @@ namespace ServiceLib.Handler.Fmt
|
||||||
item.AlterId = vmessQRCode.aid;
|
item.AlterId = vmessQRCode.aid;
|
||||||
item.Security = Utils.ToString(vmessQRCode.scy);
|
item.Security = Utils.ToString(vmessQRCode.scy);
|
||||||
|
|
||||||
item.Security = Utils.IsNotEmpty(vmessQRCode.scy) ? vmessQRCode.scy : Global.DefaultSecurity;
|
item.Security = vmessQRCode.scy.IsNotEmpty() ? vmessQRCode.scy : Global.DefaultSecurity;
|
||||||
if (Utils.IsNotEmpty(vmessQRCode.net))
|
if (vmessQRCode.net.IsNotEmpty())
|
||||||
{
|
{
|
||||||
item.Network = vmessQRCode.net;
|
item.Network = vmessQRCode.net;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(vmessQRCode.type))
|
if (vmessQRCode.type.IsNotEmpty())
|
||||||
{
|
{
|
||||||
item.HeaderType = vmessQRCode.type;
|
item.HeaderType = vmessQRCode.type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,25 +37,25 @@ namespace ServiceLib.Handler.Fmt
|
||||||
string url = string.Empty;
|
string url = string.Empty;
|
||||||
|
|
||||||
string remark = string.Empty;
|
string remark = string.Empty;
|
||||||
if (Utils.IsNotEmpty(item.Remarks))
|
if (item.Remarks.IsNotEmpty())
|
||||||
{
|
{
|
||||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||||
}
|
}
|
||||||
|
|
||||||
var dicQuery = new Dictionary<string, string>();
|
var dicQuery = new Dictionary<string, string>();
|
||||||
if (Utils.IsNotEmpty(item.PublicKey))
|
if (item.PublicKey.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("publickey", Utils.UrlEncode(item.PublicKey));
|
dicQuery.Add("publickey", Utils.UrlEncode(item.PublicKey));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Path))
|
if (item.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("reserved", Utils.UrlEncode(item.Path));
|
dicQuery.Add("reserved", Utils.UrlEncode(item.Path));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.RequestHost))
|
if (item.RequestHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("address", Utils.UrlEncode(item.RequestHost));
|
dicQuery.Add("address", Utils.UrlEncode(item.RequestHost));
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.ShortId))
|
if (item.ShortId.IsNotEmpty())
|
||||||
{
|
{
|
||||||
dicQuery.Add("mtu", Utils.UrlEncode(item.ShortId));
|
dicQuery.Add("mtu", Utils.UrlEncode(item.ShortId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
private void IndexIdEnqueue(string indexId)
|
private void IndexIdEnqueue(string indexId)
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(indexId) && !_queIndexIds.Contains(indexId))
|
if (indexId.IsNotEmpty() && !_queIndexIds.Contains(indexId))
|
||||||
{
|
{
|
||||||
_queIndexIds.Enqueue(indexId);
|
_queIndexIds.Enqueue(indexId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
if (_config.TunModeItem.EnableTun)
|
if (_config.TunModeItem.EnableTun)
|
||||||
{
|
{
|
||||||
var tun = EmbedUtils.GetEmbedText(Global.ClashTunYaml);
|
var tun = EmbedUtils.GetEmbedText(Global.ClashTunYaml);
|
||||||
if (Utils.IsNotEmpty(tun))
|
if (tun.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var tunContent = YamlUtils.FromYaml<Dictionary<string, object>>(tun);
|
var tunContent = YamlUtils.FromYaml<Dictionary<string, object>>(tun);
|
||||||
if (tunContent != null)
|
if (tunContent != null)
|
||||||
|
|
|
@ -563,7 +563,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
inbound.domain_strategy = Utils.IsNullOrEmpty(_config.RoutingBasicItem.DomainStrategy4Singbox) ? null : _config.RoutingBasicItem.DomainStrategy4Singbox;
|
inbound.domain_strategy = Utils.IsNullOrEmpty(_config.RoutingBasicItem.DomainStrategy4Singbox) ? null : _config.RoutingBasicItem.DomainStrategy4Singbox;
|
||||||
|
|
||||||
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
||||||
if (Utils.IsNotEmpty(routing.DomainStrategy4Singbox))
|
if (routing.DomainStrategy4Singbox.IsNotEmpty())
|
||||||
{
|
{
|
||||||
inbound.domain_strategy = routing.DomainStrategy4Singbox;
|
inbound.domain_strategy = routing.DomainStrategy4Singbox;
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
singboxConfig.inbounds.Add(inbound3);
|
singboxConfig.inbounds.Add(inbound3);
|
||||||
|
|
||||||
//auth
|
//auth
|
||||||
if (Utils.IsNotEmpty(_config.Inbound.First().User) && Utils.IsNotEmpty(_config.Inbound.First().Pass))
|
if (_config.Inbound.First().User.IsNotEmpty() && _config.Inbound.First().Pass.IsNotEmpty())
|
||||||
{
|
{
|
||||||
inbound3.users = new() { new() { username = _config.Inbound.First().User, password = _config.Inbound.First().Pass } };
|
inbound3.users = new() { new() { username = _config.Inbound.First().User, password = _config.Inbound.First().Pass } };
|
||||||
}
|
}
|
||||||
|
@ -674,8 +674,8 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
case EConfigType.SOCKS:
|
case EConfigType.SOCKS:
|
||||||
{
|
{
|
||||||
outbound.version = "5";
|
outbound.version = "5";
|
||||||
if (Utils.IsNotEmpty(node.Security)
|
if (node.Security.IsNotEmpty()
|
||||||
&& Utils.IsNotEmpty(node.Id))
|
&& node.Id.IsNotEmpty())
|
||||||
{
|
{
|
||||||
outbound.username = node.Security;
|
outbound.username = node.Security;
|
||||||
outbound.password = node.Id;
|
outbound.password = node.Id;
|
||||||
|
@ -684,8 +684,8 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
case EConfigType.HTTP:
|
case EConfigType.HTTP:
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(node.Security)
|
if (node.Security.IsNotEmpty()
|
||||||
&& Utils.IsNotEmpty(node.Id))
|
&& node.Id.IsNotEmpty())
|
||||||
{
|
{
|
||||||
outbound.username = node.Security;
|
outbound.username = node.Security;
|
||||||
outbound.password = node.Id;
|
outbound.password = node.Id;
|
||||||
|
@ -719,7 +719,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
{
|
{
|
||||||
outbound.password = node.Id;
|
outbound.password = node.Id;
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(node.Path))
|
if (node.Path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
outbound.obfs = new()
|
outbound.obfs = new()
|
||||||
{
|
{
|
||||||
|
@ -775,7 +775,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_config.CoreBasicItem.MuxEnabled && Utils.IsNotEmpty(_config.Mux4SboxItem.Protocol))
|
if (_config.CoreBasicItem.MuxEnabled && _config.Mux4SboxItem.Protocol.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var mux = new Multiplex4Sbox()
|
var mux = new Multiplex4Sbox()
|
||||||
{
|
{
|
||||||
|
@ -801,11 +801,11 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
if (node.StreamSecurity == Global.StreamSecurityReality || node.StreamSecurity == Global.StreamSecurity)
|
if (node.StreamSecurity == Global.StreamSecurityReality || node.StreamSecurity == Global.StreamSecurity)
|
||||||
{
|
{
|
||||||
var server_name = string.Empty;
|
var server_name = string.Empty;
|
||||||
if (Utils.IsNotEmpty(node.Sni))
|
if (node.Sni.IsNotEmpty())
|
||||||
{
|
{
|
||||||
server_name = node.Sni;
|
server_name = node.Sni;
|
||||||
}
|
}
|
||||||
else if (Utils.IsNotEmpty(node.RequestHost))
|
else if (node.RequestHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
server_name = Utils.String2List(node.RequestHost)?.First();
|
server_name = Utils.String2List(node.RequestHost)?.First();
|
||||||
}
|
}
|
||||||
|
@ -816,7 +816,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
insecure = Utils.ToBool(node.AllowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.AllowInsecure),
|
insecure = Utils.ToBool(node.AllowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.AllowInsecure),
|
||||||
alpn = node.GetAlpn(),
|
alpn = node.GetAlpn(),
|
||||||
};
|
};
|
||||||
if (Utils.IsNotEmpty(node.Fingerprint))
|
if (node.Fingerprint.IsNotEmpty())
|
||||||
{
|
{
|
||||||
tls.utls = new Utls4Sbox()
|
tls.utls = new Utls4Sbox()
|
||||||
{
|
{
|
||||||
|
@ -878,7 +878,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
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 = Utils.IsNullOrEmpty(node.Path) ? null : node.Path;
|
||||||
if (Utils.IsNotEmpty(node.RequestHost))
|
if (node.RequestHost.IsNotEmpty())
|
||||||
{
|
{
|
||||||
transport.headers = new()
|
transport.headers = new()
|
||||||
{
|
{
|
||||||
|
@ -1085,7 +1085,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
outbound = item.OutboundTag,
|
outbound = item.OutboundTag,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(item.Port))
|
if (item.Port.IsNotEmpty())
|
||||||
{
|
{
|
||||||
if (item.Port.Contains("-"))
|
if (item.Port.Contains("-"))
|
||||||
{
|
{
|
||||||
|
@ -1096,7 +1096,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
rule.port = new List<int> { Utils.ToInt(item.Port) };
|
rule.port = new List<int> { Utils.ToInt(item.Port) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(item.Network))
|
if (item.Network.IsNotEmpty())
|
||||||
{
|
{
|
||||||
rule.network = Utils.String2List(item.Network);
|
rule.network = Utils.String2List(item.Network);
|
||||||
}
|
}
|
||||||
|
@ -1290,7 +1290,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
});
|
});
|
||||||
|
|
||||||
var lstDomain = singboxConfig.outbounds
|
var lstDomain = singboxConfig.outbounds
|
||||||
.Where(t => Utils.IsNotEmpty(t.server) && Utils.IsDomain(t.server))
|
.Where(t => t.server.IsNotEmpty() && Utils.IsDomain(t.server))
|
||||||
.Select(t => t.server)
|
.Select(t => t.server)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -1394,10 +1394,10 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
List<Ruleset4Sbox> customRulesets = [];
|
List<Ruleset4Sbox> customRulesets = [];
|
||||||
|
|
||||||
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
||||||
if (Utils.IsNotEmpty(routing.CustomRulesetPath4Singbox))
|
if (routing.CustomRulesetPath4Singbox.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var result = EmbedUtils.LoadResource(routing.CustomRulesetPath4Singbox);
|
var result = EmbedUtils.LoadResource(routing.CustomRulesetPath4Singbox);
|
||||||
if (Utils.IsNotEmpty(result))
|
if (result.IsNotEmpty())
|
||||||
{
|
{
|
||||||
customRulesets = (JsonUtils.Deserialize<List<Ruleset4Sbox>>(result) ?? [])
|
customRulesets = (JsonUtils.Deserialize<List<Ruleset4Sbox>>(result) ?? [])
|
||||||
.Where(t => t.tag != null)
|
.Where(t => t.tag != null)
|
||||||
|
|
|
@ -465,7 +465,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
v2rayConfig.inbounds.Add(inbound3);
|
v2rayConfig.inbounds.Add(inbound3);
|
||||||
|
|
||||||
//auth
|
//auth
|
||||||
if (Utils.IsNotEmpty(_config.Inbound.First().User) && Utils.IsNotEmpty(_config.Inbound.First().Pass))
|
if (_config.Inbound.First().User.IsNotEmpty() && _config.Inbound.First().Pass.IsNotEmpty())
|
||||||
{
|
{
|
||||||
inbound3.settings.auth = "password";
|
inbound3.settings.auth = "password";
|
||||||
inbound3.settings.accounts = new List<AccountsItem4Ray> { new AccountsItem4Ray() { user = _config.Inbound.First().User, pass = _config.Inbound.First().Pass } };
|
inbound3.settings.accounts = new List<AccountsItem4Ray> { new AccountsItem4Ray() { user = _config.Inbound.First().User, pass = _config.Inbound.First().Pass } };
|
||||||
|
@ -520,7 +520,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
var routing = await ConfigHandler.GetDefaultRouting(_config);
|
||||||
if (routing != null)
|
if (routing != null)
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(routing.DomainStrategy))
|
if (routing.DomainStrategy.IsNotEmpty())
|
||||||
{
|
{
|
||||||
v2rayConfig.routing.domainStrategy = routing.DomainStrategy;
|
v2rayConfig.routing.domainStrategy = routing.DomainStrategy;
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
if (!hasDomainIp)
|
if (!hasDomainIp)
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(rule.port)
|
if (rule.port.IsNotEmpty()
|
||||||
|| rule.protocol?.Count > 0
|
|| rule.protocol?.Count > 0
|
||||||
|| rule.inboundTag?.Count > 0
|
|| rule.inboundTag?.Count > 0
|
||||||
)
|
)
|
||||||
|
@ -714,8 +714,8 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
serversItem.method = null;
|
serversItem.method = null;
|
||||||
serversItem.password = null;
|
serversItem.password = null;
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(node.Security)
|
if (node.Security.IsNotEmpty()
|
||||||
&& Utils.IsNotEmpty(node.Id))
|
&& node.Id.IsNotEmpty())
|
||||||
{
|
{
|
||||||
SocksUsersItem4Ray socksUsersItem = new()
|
SocksUsersItem4Ray socksUsersItem = new()
|
||||||
{
|
{
|
||||||
|
@ -868,11 +868,11 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
alpn = node.GetAlpn(),
|
alpn = node.GetAlpn(),
|
||||||
fingerprint = node.Fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.Fingerprint
|
fingerprint = node.Fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.Fingerprint
|
||||||
};
|
};
|
||||||
if (Utils.IsNotEmpty(sni))
|
if (sni.IsNotEmpty())
|
||||||
{
|
{
|
||||||
tlsSettings.serverName = sni;
|
tlsSettings.serverName = sni;
|
||||||
}
|
}
|
||||||
else if (Utils.IsNotEmpty(host))
|
else if (host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
tlsSettings.serverName = Utils.String2List(host)?.First();
|
tlsSettings.serverName = Utils.String2List(host)?.First();
|
||||||
}
|
}
|
||||||
|
@ -918,7 +918,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
type = node.HeaderType,
|
type = node.HeaderType,
|
||||||
domain = host.IsNullOrEmpty() ? null : host
|
domain = host.IsNullOrEmpty() ? null : host
|
||||||
};
|
};
|
||||||
if (Utils.IsNotEmpty(path))
|
if (path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
kcpSettings.seed = path;
|
kcpSettings.seed = path;
|
||||||
}
|
}
|
||||||
|
@ -929,16 +929,16 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
WsSettings4Ray wsSettings = new();
|
WsSettings4Ray wsSettings = new();
|
||||||
wsSettings.headers = new Headers4Ray();
|
wsSettings.headers = new Headers4Ray();
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(host))
|
if (host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
wsSettings.host = host;
|
wsSettings.host = host;
|
||||||
wsSettings.headers.Host = host;
|
wsSettings.headers.Host = host;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(path))
|
if (path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
wsSettings.path = path;
|
wsSettings.path = path;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(useragent))
|
if (useragent.IsNotEmpty())
|
||||||
{
|
{
|
||||||
wsSettings.headers.UserAgent = useragent;
|
wsSettings.headers.UserAgent = useragent;
|
||||||
}
|
}
|
||||||
|
@ -949,11 +949,11 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
case nameof(ETransport.httpupgrade):
|
case nameof(ETransport.httpupgrade):
|
||||||
HttpupgradeSettings4Ray httpupgradeSettings = new();
|
HttpupgradeSettings4Ray httpupgradeSettings = new();
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(path))
|
if (path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
httpupgradeSettings.path = path;
|
httpupgradeSettings.path = path;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(host))
|
if (host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
httpupgradeSettings.host = host;
|
httpupgradeSettings.host = host;
|
||||||
}
|
}
|
||||||
|
@ -965,19 +965,19 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
streamSettings.network = ETransport.xhttp.ToString();
|
streamSettings.network = ETransport.xhttp.ToString();
|
||||||
XhttpSettings4Ray xhttpSettings = new();
|
XhttpSettings4Ray xhttpSettings = new();
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(path))
|
if (path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
xhttpSettings.path = path;
|
xhttpSettings.path = path;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(host))
|
if (host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
xhttpSettings.host = host;
|
xhttpSettings.host = host;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(node.HeaderType) && Global.XhttpMode.Contains(node.HeaderType))
|
if (node.HeaderType.IsNotEmpty() && Global.XhttpMode.Contains(node.HeaderType))
|
||||||
{
|
{
|
||||||
xhttpSettings.mode = node.HeaderType;
|
xhttpSettings.mode = node.HeaderType;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(node.Extra))
|
if (node.Extra.IsNotEmpty())
|
||||||
{
|
{
|
||||||
xhttpSettings.extra = JsonUtils.ParseJson(node.Extra);
|
xhttpSettings.extra = JsonUtils.ParseJson(node.Extra);
|
||||||
}
|
}
|
||||||
|
@ -990,7 +990,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
case nameof(ETransport.h2):
|
case nameof(ETransport.h2):
|
||||||
HttpSettings4Ray httpSettings = new();
|
HttpSettings4Ray httpSettings = new();
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(host))
|
if (host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
httpSettings.host = Utils.String2List(host);
|
httpSettings.host = Utils.String2List(host);
|
||||||
}
|
}
|
||||||
|
@ -1013,7 +1013,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
streamSettings.quicSettings = quicsettings;
|
streamSettings.quicSettings = quicsettings;
|
||||||
if (node.StreamSecurity == Global.StreamSecurity)
|
if (node.StreamSecurity == Global.StreamSecurity)
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(sni))
|
if (sni.IsNotEmpty())
|
||||||
{
|
{
|
||||||
streamSettings.tlsSettings.serverName = sni;
|
streamSettings.tlsSettings.serverName = sni;
|
||||||
}
|
}
|
||||||
|
@ -1058,7 +1058,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
request = request.Replace("$requestUserAgent$", $"{useragent.AppendQuotes()}");
|
request = request.Replace("$requestUserAgent$", $"{useragent.AppendQuotes()}");
|
||||||
//Path
|
//Path
|
||||||
string pathHttp = @"/";
|
string pathHttp = @"/";
|
||||||
if (Utils.IsNotEmpty(path))
|
if (path.IsNotEmpty())
|
||||||
{
|
{
|
||||||
string[] arrPath = path.Split(',');
|
string[] arrPath = path.Split(',');
|
||||||
pathHttp = string.Join(",".AppendQuotes(), arrPath);
|
pathHttp = string.Join(",".AppendQuotes(), arrPath);
|
||||||
|
@ -1091,7 +1091,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
//Outbound Freedom domainStrategy
|
//Outbound Freedom domainStrategy
|
||||||
if (Utils.IsNotEmpty(domainStrategy4Freedom))
|
if (domainStrategy4Freedom.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var outbound = v2rayConfig.outbounds.FirstOrDefault(t => t is { protocol: "freedom", tag: Global.DirectTag });
|
var outbound = v2rayConfig.outbounds.FirstOrDefault(t => t is { protocol: "freedom", tag: Global.DirectTag });
|
||||||
if (outbound != null)
|
if (outbound != null)
|
||||||
|
@ -1216,7 +1216,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
{
|
{
|
||||||
//fragment proxy
|
//fragment proxy
|
||||||
if (_config.CoreBasicItem.EnableFragment
|
if (_config.CoreBasicItem.EnableFragment
|
||||||
&& Utils.IsNotEmpty(v2rayConfig.outbounds.First().streamSettings?.security))
|
&& v2rayConfig.outbounds.First().streamSettings?.security.IsNullOrEmpty() == false)
|
||||||
{
|
{
|
||||||
var fragmentOutbound = new Outbounds4Ray
|
var fragmentOutbound = new Outbounds4Ray
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace ServiceLib.Services
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result1 = await DownloadStringAsync(url, blProxy, userAgent, 15);
|
var result1 = await DownloadStringAsync(url, blProxy, userAgent, 15);
|
||||||
if (Utils.IsNotEmpty(result1))
|
if (result1.IsNotEmpty())
|
||||||
{
|
{
|
||||||
return result1;
|
return result1;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ namespace ServiceLib.Services
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result2 = await DownloadStringViaDownloader(url, blProxy, userAgent, 15);
|
var result2 = await DownloadStringViaDownloader(url, blProxy, userAgent, 15);
|
||||||
if (Utils.IsNotEmpty(result2))
|
if (result2.IsNotEmpty())
|
||||||
{
|
{
|
||||||
return result2;
|
return result2;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ namespace ServiceLib.Services
|
||||||
|
|
||||||
Uri uri = new(url);
|
Uri uri = new(url);
|
||||||
//Authorization Header
|
//Authorization Header
|
||||||
if (Utils.IsNotEmpty(uri.UserInfo))
|
if (uri.UserInfo.IsNotEmpty())
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Utils.Base64Encode(uri.UserInfo));
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Utils.Base64Encode(uri.UserInfo));
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace ServiceLib.Services.Statistics
|
||||||
while (!res.CloseStatus.HasValue)
|
while (!res.CloseStatus.HasValue)
|
||||||
{
|
{
|
||||||
var result = Encoding.UTF8.GetString(buffer, 0, res.Count);
|
var result = Encoding.UTF8.GetString(buffer, 0, res.Count);
|
||||||
if (Utils.IsNotEmpty(result))
|
if (result.IsNotEmpty())
|
||||||
{
|
{
|
||||||
ParseOutput(result, out ulong up, out ulong down);
|
ParseOutput(result, out ulong up, out ulong down);
|
||||||
|
|
||||||
|
|
|
@ -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) || (Utils.IsNotEmpty(subId) && item.Id != subId))
|
if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url) || (subId.IsNotEmpty() && item.Id != subId))
|
||||||
{
|
{
|
||||||
//_updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
|
//_updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
|
||||||
continue;
|
continue;
|
||||||
|
@ -149,7 +149,7 @@ namespace ServiceLib.Services
|
||||||
//one url
|
//one url
|
||||||
url = Utils.GetPunycode(url);
|
url = Utils.GetPunycode(url);
|
||||||
//convert
|
//convert
|
||||||
if (Utils.IsNotEmpty(item.ConvertTarget))
|
if (item.ConvertTarget.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var subConvertUrl = Utils.IsNullOrEmpty(config.ConstItem.SubConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.ConstItem.SubConvertUrl;
|
var subConvertUrl = Utils.IsNullOrEmpty(config.ConstItem.SubConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.ConstItem.SubConvertUrl;
|
||||||
url = string.Format(subConvertUrl!, Utils.UrlEncode(url));
|
url = string.Format(subConvertUrl!, Utils.UrlEncode(url));
|
||||||
|
@ -169,9 +169,9 @@ namespace ServiceLib.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
//more url
|
//more url
|
||||||
if (Utils.IsNullOrEmpty(item.ConvertTarget) && Utils.IsNotEmpty(item.MoreUrl.TrimEx()))
|
if (Utils.IsNullOrEmpty(item.ConvertTarget) && item.MoreUrl.TrimEx().IsNotEmpty())
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(result) && Utils.IsBase64String(result))
|
if (result.IsNotEmpty() && Utils.IsBase64String(result))
|
||||||
{
|
{
|
||||||
result = Utils.Base64Decode(result);
|
result = Utils.Base64Decode(result);
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ namespace ServiceLib.Services
|
||||||
{
|
{
|
||||||
result2 = await downloadHandle.TryDownloadString(url2, false, userAgent);
|
result2 = await downloadHandle.TryDownloadString(url2, false, userAgent);
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(result2))
|
if (result2.IsNotEmpty())
|
||||||
{
|
{
|
||||||
if (Utils.IsBase64String(result2))
|
if (Utils.IsBase64String(result2))
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,7 +80,7 @@ namespace ServiceLib.ViewModels
|
||||||
if (await ConfigHandler.AddCustomServer(_config, item, false) == 0)
|
if (await ConfigHandler.AddCustomServer(_config, item, false) == 0)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer);
|
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer);
|
||||||
if (Utils.IsNotEmpty(item.IndexId))
|
if (item.IndexId.IsNotEmpty())
|
||||||
{
|
{
|
||||||
SelectedSource = JsonUtils.DeepCopy(item);
|
SelectedSource = JsonUtils.DeepCopy(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
var canEditRemove = this.WhenAnyValue(
|
var canEditRemove = this.WhenAnyValue(
|
||||||
x => x.SelectedSource,
|
x => x.SelectedSource,
|
||||||
selectedSource => selectedSource != null && Utils.IsNotEmpty(selectedSource.Id));
|
selectedSource => selectedSource != null && selectedSource.Id.IsNotEmpty());
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.AutoRefresh,
|
x => x.AutoRefresh,
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.SelectedGroup,
|
x => x.SelectedGroup,
|
||||||
y => y != null && Utils.IsNotEmpty(y.Name))
|
y => y != null && y.Name.IsNotEmpty())
|
||||||
.Subscribe(c => RefreshProxyDetails(c));
|
.Subscribe(c => RefreshProxyDetails(c));
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
|
@ -219,7 +219,7 @@ namespace ServiceLib.ViewModels
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var item = _proxyGroups.Where(t => t.Name == kv.Key).FirstOrDefault();
|
var item = _proxyGroups.Where(t => t.Name == kv.Key).FirstOrDefault();
|
||||||
if (item != null && Utils.IsNotEmpty(item.Name))
|
if (item != null && item.Name.IsNotEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private async Task SaveSettingAsync()
|
private async Task SaveSettingAsync()
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(normalDNS))
|
if (normalDNS.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var obj = JsonUtils.ParseJson(normalDNS);
|
var obj = JsonUtils.ParseJson(normalDNS);
|
||||||
if (obj != null && obj["servers"] != null)
|
if (obj != null && obj["servers"] != null)
|
||||||
|
@ -77,7 +77,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(normalDNS2))
|
if (normalDNS2.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(normalDNS2);
|
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(normalDNS2);
|
||||||
if (obj2 == null)
|
if (obj2 == null)
|
||||||
|
@ -86,7 +86,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(tunDNS2))
|
if (tunDNS2.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(tunDNS2);
|
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(tunDNS2);
|
||||||
if (obj2 == null)
|
if (obj2 == null)
|
||||||
|
|
|
@ -279,13 +279,13 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsNotEmpty(result.Delay))
|
if (result.Delay.IsNotEmpty())
|
||||||
{
|
{
|
||||||
int.TryParse(result.Delay, out var temp);
|
int.TryParse(result.Delay, out var temp);
|
||||||
item.Delay = temp;
|
item.Delay = temp;
|
||||||
item.DelayVal = result.Delay ?? string.Empty;
|
item.DelayVal = result.Delay ?? string.Empty;
|
||||||
}
|
}
|
||||||
if (Utils.IsNotEmpty(result.Speed))
|
if (result.Speed.IsNotEmpty())
|
||||||
{
|
{
|
||||||
item.SpeedVal = result.Speed ?? string.Empty;
|
item.SpeedVal = result.Speed ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,8 @@ namespace ServiceLib.ViewModels
|
||||||
|| SelectedSource.Ip?.Count > 0
|
|| SelectedSource.Ip?.Count > 0
|
||||||
|| SelectedSource.Protocol?.Count > 0
|
|| SelectedSource.Protocol?.Count > 0
|
||||||
|| SelectedSource.Process?.Count > 0
|
|| SelectedSource.Process?.Count > 0
|
||||||
|| Utils.IsNotEmpty(SelectedSource.Port)
|
|| SelectedSource.Port.IsNotEmpty()
|
||||||
|| Utils.IsNotEmpty(SelectedSource.Network);
|
|| SelectedSource.Network.IsNotEmpty();
|
||||||
|
|
||||||
if (!hasRule)
|
if (!hasRule)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace v2rayN.Desktop.ViewModels
|
||||||
y => y != null && !y.IsNullOrEmpty())
|
y => y != null && !y.IsNullOrEmpty())
|
||||||
.Subscribe(c =>
|
.Subscribe(c =>
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(CurrentLanguage) && _config.UiItem.CurrentLanguage != CurrentLanguage)
|
if (CurrentLanguage.IsNotEmpty() && _config.UiItem.CurrentLanguage != CurrentLanguage)
|
||||||
{
|
{
|
||||||
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
||||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace v2rayN.Converters
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fontFamily = AppHandler.Instance.Config.UiItem.CurrentFontFamily;
|
var fontFamily = AppHandler.Instance.Config.UiItem.CurrentFontFamily;
|
||||||
if (Utils.IsNotEmpty(fontFamily))
|
if (fontFamily.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var fontPath = Utils.GetFontsPath();
|
var fontPath = Utils.GetFontsPath();
|
||||||
MyFont = new FontFamily(new Uri(@$"file:///{fontPath}\"), $"./#{fontFamily}");
|
MyFont = new FontFamily(new Uri(@$"file:///{fontPath}\"), $"./#{fontFamily}");
|
||||||
|
|
|
@ -116,7 +116,7 @@ namespace v2rayN.ViewModels
|
||||||
y => y != null && !y.IsNullOrEmpty())
|
y => y != null && !y.IsNullOrEmpty())
|
||||||
.Subscribe(c =>
|
.Subscribe(c =>
|
||||||
{
|
{
|
||||||
if (Utils.IsNotEmpty(CurrentLanguage) && _config.UiItem.CurrentLanguage != CurrentLanguage)
|
if (CurrentLanguage.IsNotEmpty() && _config.UiItem.CurrentLanguage != CurrentLanguage)
|
||||||
{
|
{
|
||||||
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
||||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||||
|
|
Loading…
Reference in a new issue