mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 20:09:12 +00:00
Compare commits
2 commits
66efb0f355
...
eb42583819
Author | SHA1 | Date | |
---|---|---|---|
![]() |
eb42583819 | ||
![]() |
6808595fa1 |
2 changed files with 47 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
@ -10,4 +11,48 @@ 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,7 +496,8 @@ public partial class CoreConfigV2rayService
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasCycle = await node.HasCycle(new HashSet<string>(), new HashSet<string>());
|
var hasCycle = profileGroupItem.HasCycle();
|
||||||
|
//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