mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-14 04:19:12 +00:00
Compare commits
1 commit
eb42583819
...
66efb0f355
Author | SHA1 | Date | |
---|---|---|---|
![]() |
66efb0f355 |
2 changed files with 1 additions and 47 deletions
|
@ -1,5 +1,4 @@
|
||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
@ -11,48 +10,4 @@ public class ProfileGroupItem
|
||||||
public string ChildItems { get; set; }
|
public string ChildItems { get; set; }
|
||||||
|
|
||||||
public EMultipleLoad MultipleLoad { get; set; } = EMultipleLoad.LeastPing;
|
public EMultipleLoad MultipleLoad { get; set; } = EMultipleLoad.LeastPing;
|
||||||
|
|
||||||
public bool HasCycle()
|
|
||||||
{
|
|
||||||
return HasCycle(new HashSet<string>(), new HashSet<string>());
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasCycle(HashSet<string> visited, HashSet<string> stack)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(ParentIndexId))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (stack.Contains(ParentIndexId))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (visited.Contains(ParentIndexId))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
visited.Add(ParentIndexId);
|
|
||||||
stack.Add(ParentIndexId);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(ChildItems))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var childIds = Utils.String2List(ChildItems)
|
|
||||||
.Where(p => !string.IsNullOrEmpty(p))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var childProfiles = childIds.Select(ProfileGroupItemManager.Instance.GetOrDefault)//这里是内存访问
|
|
||||||
.Where(p => p != null)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var child in childProfiles)
|
|
||||||
{
|
|
||||||
if (child.HasCycle(visited, stack))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stack.Remove(ParentIndexId);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -496,8 +496,7 @@ public partial class CoreConfigV2rayService
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasCycle = profileGroupItem.HasCycle();
|
var hasCycle = await node.HasCycle(new HashSet<string>(), new HashSet<string>());
|
||||||
//var hasCycle = await node.HasCycle(new HashSet<string>(), new HashSet<string>());
|
|
||||||
if (hasCycle)
|
if (hasCycle)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in a new issue