Add Policy Group support

This commit is contained in:
DHR60 2025-09-11 13:00:12 +08:00
parent 34327532e6
commit 9ef228db1e
2 changed files with 40 additions and 0 deletions

View file

@ -15,6 +15,26 @@ public partial class CoreConfigSingboxService(Config config)
var ret = new RetResult(); var ret = new RetResult();
try try
{ {
if (node?.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
ProfileGroupItemManager.Instance.TryGet(node.IndexId, out var profileGroupItem);
if (profileGroupItem == null || profileGroupItem.ChildItems.IsNullOrEmpty())
{
ret.Msg = ResUI.CheckServerSettings;
return ret;
}
if (node.ConfigType is EConfigType.PolicyGroup)
{
var childProfiles = (await Task.WhenAll(
Utils.String2List(profileGroupItem.ChildItems)
.Where(p => !p.IsNullOrEmpty())
.Select(AppManager.Instance.GetProfileItem)
)).Where(p => p != null).ToList();
return await GenerateClientMultipleLoadConfig(childProfiles);
}
// TODO proxy chain
}
if (node == null if (node == null
|| node.Port <= 0) || node.Port <= 0)
{ {

View file

@ -15,6 +15,26 @@ public partial class CoreConfigV2rayService(Config config)
var ret = new RetResult(); var ret = new RetResult();
try try
{ {
if (node?.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
ProfileGroupItemManager.Instance.TryGet(node.IndexId, out var profileGroupItem);
if (profileGroupItem == null || profileGroupItem.ChildItems.IsNullOrEmpty())
{
ret.Msg = ResUI.CheckServerSettings;
return ret;
}
if (node.ConfigType is EConfigType.PolicyGroup)
{
var childProfiles = (await Task.WhenAll(
Utils.String2List(profileGroupItem.ChildItems)
.Where(p => !p.IsNullOrEmpty())
.Select(AppManager.Instance.GetProfileItem)
)).Where(p => p != null).ToList();
return await GenerateClientMultipleLoadConfig(childProfiles, profileGroupItem.MultipleLoad);
}
// TODO proxy chain
}
if (node == null if (node == null
|| node.Port <= 0) || node.Port <= 0)
{ {