Optimize add batch servers

pull/3621/head
2dust 2023-04-06 11:40:28 +08:00
parent f28b93daa0
commit 84eba671f0
2 changed files with 16 additions and 2 deletions

View File

@ -945,7 +945,7 @@ namespace v2rayN.Handler
foreach (string str in arrData)
{
//maybe sub
if (Utils.IsNullOrEmpty(subid) && (str.StartsWith(Global.httpsProtocol) || str.StartsWith(Global.httpProtocol)))
if (!isSub && (str.StartsWith(Global.httpsProtocol) || str.StartsWith(Global.httpProtocol)))
{
if (AddSubItem(ref config, str) == 0)
{
@ -1187,7 +1187,15 @@ namespace v2rayN.Handler
lstOriSub = LazyConfig.Instance.ProfileItems(subid);
}
int counter = AddBatchServers(ref config, clipboardData, subid, isSub, lstOriSub);
var counter = 0;
if (Utils.IsBase64String(clipboardData))
{
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
}
if (counter < 1)
{
counter = AddBatchServers(ref config, clipboardData, subid, isSub, lstOriSub);
}
if (counter < 1)
{
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);

View File

@ -453,6 +453,12 @@ namespace v2rayN
}
}
public static bool IsBase64String(string plainText)
{
var buffer = new Span<byte>(new byte[plainText.Length]);
return Convert.TryFromBase64String(plainText, buffer, out int _);
}
#endregion