mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 20:09:12 +00:00
Compare commits
25 commits
15d51c41fc
...
c9ed6c1ea8
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c9ed6c1ea8 | ||
![]() |
4bf86665b7 | ||
![]() |
ae46b39110 | ||
![]() |
836217266e | ||
![]() |
4e3c2991f9 | ||
![]() |
cdab7a097f | ||
![]() |
1d8b8491ea | ||
![]() |
04dae54654 | ||
![]() |
63bf68376f | ||
![]() |
826f9f833a | ||
![]() |
9317c73084 | ||
![]() |
2d5a5465df | ||
![]() |
af62d9e0f4 | ||
![]() |
2ab044b4fc | ||
![]() |
c76d125ce1 | ||
![]() |
183be53153 | ||
![]() |
52d1eb1e2b | ||
![]() |
521dca33d5 | ||
![]() |
a323484ee3 | ||
![]() |
9a43003c47 | ||
![]() |
e97b98f4bf | ||
![]() |
bd3a733057 | ||
![]() |
0cde086448 | ||
![]() |
8561311a45 | ||
![]() |
57fd56fc05 |
3 changed files with 50 additions and 2 deletions
|
@ -109,6 +109,42 @@ public class ProfileItem : ReactiveObject
|
||||||
return true;
|
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
|
#endregion function
|
||||||
|
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
|
|
|
@ -217,9 +217,15 @@ public partial class CoreConfigSingboxService
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasCycle = await node.HasCycle(new HashSet<string>(), new HashSet<string>());
|
||||||
|
if (hasCycle)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// remove custom nodes
|
// remove custom nodes
|
||||||
// remove group nodes for proxy chain
|
// remove group nodes for proxy chain
|
||||||
// avoid self-reference
|
|
||||||
var childProfiles = (await Task.WhenAll(
|
var childProfiles = (await Task.WhenAll(
|
||||||
Utils.String2List(profileGroupItem.ChildItems)
|
Utils.String2List(profileGroupItem.ChildItems)
|
||||||
.Where(p => !p.IsNullOrEmpty())
|
.Where(p => !p.IsNullOrEmpty())
|
||||||
|
@ -230,7 +236,6 @@ public partial class CoreConfigSingboxService
|
||||||
&& p.IsValid()
|
&& p.IsValid()
|
||||||
&& p.ConfigType != EConfigType.Custom
|
&& p.ConfigType != EConfigType.Custom
|
||||||
&& (node.ConfigType == EConfigType.PolicyGroup || p.ConfigType < EConfigType.Group)
|
&& (node.ConfigType == EConfigType.PolicyGroup || p.ConfigType < EConfigType.Group)
|
||||||
&& p.IndexId != node.IndexId
|
|
||||||
)
|
)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|
|
@ -493,6 +493,13 @@ public partial class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasCycle = await node.HasCycle(new HashSet<string>(), new HashSet<string>());
|
||||||
|
if (hasCycle)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// remove custom nodes
|
// remove custom nodes
|
||||||
// remove group nodes for proxy chain
|
// remove group nodes for proxy chain
|
||||||
var childProfiles = (await Task.WhenAll(
|
var childProfiles = (await Task.WhenAll(
|
||||||
|
|
Loading…
Reference in a new issue