Optimize code ,add IsGroupType extension. Adjust EConfigType

This commit is contained in:
2dust
2025-10-08 17:13:54 +08:00
parent a559586e71
commit 91af50f99a
17 changed files with 37 additions and 26 deletions
@@ -1,5 +1,6 @@
using System.Net;
using System.Net.NetworkInformation;
using ServiceLib.Common;
namespace ServiceLib.Services.CoreConfig;
@@ -29,7 +30,7 @@ public partial class CoreConfigSingboxService(Config config)
ret.Msg = ResUI.InitialConfiguration;
if (node?.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (node.ConfigType.IsGroupType())
{
switch (node.ConfigType)
{
@@ -208,7 +208,7 @@ public partial class CoreConfigSingboxService
{
try
{
if (node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain))
if (!node.ConfigType.IsGroupType())
{
return -1;
}
@@ -494,7 +494,7 @@ public partial class CoreConfigSingboxService
{
index++;
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (node.ConfigType.IsGroupType())
{
var (childProfiles, profileGroupItem) = await ProfileGroupItemManager.GetChildProfileItems(node.IndexId);
if (childProfiles.Count <= 0)
@@ -669,7 +669,7 @@ public partial class CoreConfigSingboxService
var node = nodes[i];
if (node == null)
continue;
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (node.ConfigType.IsGroupType())
{
var (childProfiles, profileGroupItem) = await ProfileGroupItemManager.GetChildProfileItems(node.IndexId);
if (childProfiles.Count <= 0)
@@ -379,7 +379,7 @@ public partial class CoreConfigSingboxService
if (node == null
|| (!Global.SingboxSupportConfigType.Contains(node.ConfigType)
&& node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain)))
&& !node.ConfigType.IsGroupType()))
{
return Global.ProxyTag;
}
@@ -391,7 +391,7 @@ public partial class CoreConfigSingboxService
return tag;
}
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (node.ConfigType.IsGroupType())
{
var ret = await GenGroupOutbound(node, singboxConfig, tag);
if (ret == 0)
@@ -30,7 +30,7 @@ public partial class CoreConfigV2rayService(Config config)
ret.Msg = ResUI.InitialConfiguration;
if (node?.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (node.ConfigType.IsGroupType())
{
switch (node.ConfigType)
{
@@ -484,7 +484,7 @@ public partial class CoreConfigV2rayService
{
try
{
if (node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain))
if (!node.ConfigType.IsGroupType())
{
return -1;
}
@@ -631,7 +631,7 @@ public partial class CoreConfigV2rayService
{
index++;
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (node.ConfigType.IsGroupType())
{
var (childProfiles, _) = await ProfileGroupItemManager.GetChildProfileItems(node.IndexId);
if (childProfiles.Count <= 0)
@@ -782,7 +782,7 @@ public partial class CoreConfigV2rayService
var node = nodes[i];
if (node == null)
continue;
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (node.ConfigType.IsGroupType())
{
var (childProfiles, _) = await ProfileGroupItemManager.GetChildProfileItems(node.IndexId);
if (childProfiles.Count <= 0)
@@ -135,7 +135,7 @@ public partial class CoreConfigV2rayService
if (node == null
|| (!Global.XraySupportConfigType.Contains(node.ConfigType)
&& node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain)))
&& !node.ConfigType.IsGroupType()))
{
return Global.ProxyTag;
}
@@ -146,7 +146,7 @@ public partial class CoreConfigV2rayService
return tag;
}
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (node.ConfigType.IsGroupType())
{
var ret = await GenGroupOutbound(node, v2rayConfig, tag);
if (ret == 0)
@@ -64,7 +64,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
var lstSelected = new List<ServerTestItem>();
foreach (var it in selecteds)
{
if (it.ConfigType is EConfigType.Custom or EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (it.ConfigType.IsComplexType())
{
continue;
}
@@ -339,7 +339,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
{
List<List<ServerTestItem>> lstTest = new();
var lst1 = lstSelected.Where(t => Global.XraySupportConfigType.Contains(t.ConfigType)).ToList();
var lst2 = lstSelected.Where(t => Global.SingboxSupportConfigType.Contains(t.ConfigType) && !Global.XraySupportConfigType.Contains(t.ConfigType)).ToList();
var lst2 = lstSelected.Where(t => Global.SingboxOnlyConfigType.Contains(t.ConfigType)).ToList();
for (var num = 0; num < (int)Math.Ceiling(lst1.Count * 1.0 / pageSize); num++)
{