mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 20:09:12 +00:00
Compare commits
24 commits
c9ed6c1ea8
...
15d51c41fc
Author | SHA1 | Date | |
---|---|---|---|
![]() |
15d51c41fc | ||
![]() |
c88bf796f4 | ||
![]() |
ab1dc45ed4 | ||
![]() |
2d41272659 | ||
![]() |
e7f75010d3 | ||
![]() |
aa1ccdd01b | ||
![]() |
b17323c982 | ||
![]() |
71dcd8d1de | ||
![]() |
dace865e6c | ||
![]() |
fad94e68d2 | ||
![]() |
c116aae242 | ||
![]() |
ff1c9093a2 | ||
![]() |
8bb20c0ab8 | ||
![]() |
17a3a516c7 | ||
![]() |
8f0d7e54d8 | ||
![]() |
2ab79afa02 | ||
![]() |
e29d292732 | ||
![]() |
9ef228db1e | ||
![]() |
34327532e6 | ||
![]() |
8af6eda165 | ||
![]() |
f979d13109 | ||
![]() |
6166b6c0e3 | ||
![]() |
8c094dd976 | ||
![]() |
5c4f485471 |
3 changed files with 2 additions and 50 deletions
|
@ -109,42 +109,6 @@ public class ProfileItem : ReactiveObject
|
|||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> HasCycle(HashSet<string> visited, HashSet<string> stack)
|
||||
{
|
||||
if (ConfigType < EConfigType.Group)
|
||||
return false;
|
||||
|
||||
if (stack.Contains(IndexId))
|
||||
return true;
|
||||
|
||||
if (visited.Contains(IndexId))
|
||||
return false;
|
||||
|
||||
visited.Add(IndexId);
|
||||
stack.Add(IndexId);
|
||||
|
||||
if (ProfileGroupItemManager.Instance.TryGet(IndexId, out var group)
|
||||
&& !group.ChildItems.IsNullOrEmpty())
|
||||
{
|
||||
var childProfiles = (await Task.WhenAll(
|
||||
Utils.String2List(group.ChildItems)
|
||||
.Where(p => !p.IsNullOrEmpty())
|
||||
.Select(AppManager.Instance.GetProfileItem)
|
||||
))
|
||||
.Where(p => p != null)
|
||||
.ToList();
|
||||
|
||||
foreach (var child in childProfiles)
|
||||
{
|
||||
if (await child.HasCycle(visited, stack))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
stack.Remove(IndexId);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion function
|
||||
|
||||
[PrimaryKey]
|
||||
|
|
|
@ -217,15 +217,9 @@ public partial class CoreConfigSingboxService
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
var hasCycle = await node.HasCycle(new HashSet<string>(), new HashSet<string>());
|
||||
if (hasCycle)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// remove custom nodes
|
||||
// remove group nodes for proxy chain
|
||||
// avoid self-reference
|
||||
var childProfiles = (await Task.WhenAll(
|
||||
Utils.String2List(profileGroupItem.ChildItems)
|
||||
.Where(p => !p.IsNullOrEmpty())
|
||||
|
@ -236,6 +230,7 @@ public partial class CoreConfigSingboxService
|
|||
&& p.IsValid()
|
||||
&& p.ConfigType != EConfigType.Custom
|
||||
&& (node.ConfigType == EConfigType.PolicyGroup || p.ConfigType < EConfigType.Group)
|
||||
&& p.IndexId != node.IndexId
|
||||
)
|
||||
.ToList();
|
||||
|
||||
|
|
|
@ -493,13 +493,6 @@ public partial class CoreConfigV2rayService
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
var hasCycle = await node.HasCycle(new HashSet<string>(), new HashSet<string>());
|
||||
if (hasCycle)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// remove custom nodes
|
||||
// remove group nodes for proxy chain
|
||||
var childProfiles = (await Task.WhenAll(
|
||||
|
|
Loading…
Reference in a new issue