Merge remote-tracking branch 'origin/master'

This commit is contained in:
SoHugePenguin 2025-10-08 19:37:41 +08:00
commit 972c4cd7ad
17 changed files with 37 additions and 26 deletions

View file

@ -84,4 +84,14 @@ public static class Extension
{
return source.Concat(new[] { string.Empty }).ToList();
}
public static bool IsGroupType(this EConfigType configType)
{
return configType is EConfigType.PolicyGroup or EConfigType.ProxyChain;
}
public static bool IsComplexType(this EConfigType configType)
{
return configType is EConfigType.Custom or EConfigType.PolicyGroup or EConfigType.ProxyChain;
}
}

View file

@ -13,8 +13,6 @@ public enum EConfigType
WireGuard = 9,
HTTP = 10,
Anytls = 11,
Group = 1000,
PolicyGroup = 1001,
ProxyChain = 1002,
PolicyGroup = 101,
ProxyChain = 102,
}

View file

@ -316,6 +316,8 @@ public class Global
EConfigType.HTTP,
];
public static readonly HashSet<EConfigType> SingboxOnlyConfigType = SingboxSupportConfigType.Except(XraySupportConfigType).ToHashSet();
public static readonly List<string> DomainStrategies =
[
AsIs,

View file

@ -357,7 +357,7 @@ public static class ConfigHandler
{
}
}
else if (profileItem.ConfigType > EConfigType.Group)
else if (profileItem.ConfigType.IsGroupType())
{
var profileGroupItem = await AppManager.Instance.GetProfileGroupItem(it.IndexId);
await AddGroupServerCommon(config, profileItem, profileGroupItem, true);
@ -1255,7 +1255,7 @@ public static class ConfigHandler
if (node.ConfigType != EConfigType.Custom && coreType != ECoreType.sing_box && config.TunModeItem.EnableTun)
{
var tun2SocksAddress = node.Address;
if (node.ConfigType > EConfigType.Group)
if (node.ConfigType.IsGroupType())
{
var lstAddresses = (await ProfileGroupItemManager.GetAllChildDomainAddresses(node.IndexId)).ToList();
if (lstAddresses.Count > 0)

View file

@ -112,7 +112,7 @@ public class ActionPrecheckManager(Config config)
}
}
if (item.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
if (item.ConfigType.IsGroupType())
{
ProfileGroupItemManager.Instance.TryGet(item.IndexId, out var group);
if (group is null || group.ChildItems.IsNullOrEmpty())

View file

@ -95,7 +95,7 @@ public class CoreManager
public async Task<ProcessService?> LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
{
var coreType = selecteds.Exists(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.Anytls) ? ECoreType.sing_box : ECoreType.Xray;
var coreType = selecteds.Any(t => Global.SingboxOnlyConfigType.Contains(t.ConfigType)) ? ECoreType.sing_box : ECoreType.Xray;
var fileName = string.Format(Global.CoreSpeedtestConfigFileName, Utils.GetGuid(false));
var configPath = Utils.GetBinConfigPath(fileName);
var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType);

View file

@ -269,7 +269,7 @@ public class ProfileGroupItemManager
{
childAddresses.Add(childNode.Address);
}
else if (childNode.ConfigType > EConfigType.Group)
else if (childNode.ConfigType.IsGroupType())
{
var subAddresses = await GetAllChildDomainAddresses(childNode.IndexId);
foreach (var addr in subAddresses)

View file

@ -66,7 +66,7 @@ public class ProfileItem : ReactiveObject
public bool IsComplex()
{
return ConfigType is EConfigType.Custom or > EConfigType.Group;
return ConfigType.IsComplexType();
}
public bool IsValid()

View file

@ -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)
{

View file

@ -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)

View file

@ -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)

View file

@ -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)
{

View file

@ -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)

View file

@ -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)

View file

@ -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++)
{

View file

@ -350,7 +350,7 @@ public class MainWindowViewModel : MyReactiveObject
{
ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item);
}
else if (eConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
else if (eConfigType.IsGroupType())
{
ret = await _updateView?.Invoke(EViewAction.AddGroupServerWindow, item);
}

View file

@ -510,7 +510,7 @@ public class ProfilesViewModel : MyReactiveObject
{
ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item);
}
else if (eConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
else if (eConfigType.IsGroupType())
{
ret = await _updateView?.Invoke(EViewAction.AddGroupServerWindow, item);
}