Adds Xray and Singbox config type support

This commit is contained in:
DHR60 2025-07-28 23:48:01 +08:00
parent 7b7fe0ef46
commit 79236ae134
9 changed files with 42 additions and 37 deletions

View file

@ -289,6 +289,31 @@ public class Global
"sing_box" "sing_box"
]; ];
public static readonly HashSet<EConfigType> XraySupportConfigType =
[
EConfigType.VMess,
EConfigType.VLESS,
EConfigType.Shadowsocks,
EConfigType.Trojan,
EConfigType.WireGuard,
EConfigType.SOCKS,
EConfigType.HTTP,
];
public static readonly HashSet<EConfigType> SingboxSupportConfigType =
[
EConfigType.VMess,
EConfigType.VLESS,
EConfigType.Shadowsocks,
EConfigType.Trojan,
EConfigType.Hysteria2,
EConfigType.TUIC,
EConfigType.Anytls,
EConfigType.WireGuard,
EConfigType.SOCKS,
EConfigType.HTTP,
];
public static readonly List<string> DomainStrategies = public static readonly List<string> DomainStrategies =
[ [
AsIs, AsIs,

View file

@ -133,7 +133,7 @@ public partial class CoreConfigSingboxService(Config config)
foreach (var it in selecteds) foreach (var it in selecteds)
{ {
if (it.ConfigType == EConfigType.Custom) if (!Global.SingboxSupportConfigType.Contains(it.ConfigType))
{ {
continue; continue;
} }
@ -381,7 +381,7 @@ public partial class CoreConfigSingboxService(Config config)
var proxyProfiles = new List<ProfileItem>(); var proxyProfiles = new List<ProfileItem>();
foreach (var it in selecteds) foreach (var it in selecteds)
{ {
if (it.ConfigType == EConfigType.Custom) if (!Global.SingboxSupportConfigType.Contains(it.ConfigType))
{ {
continue; continue;
} }

View file

@ -372,7 +372,7 @@ public partial class CoreConfigSingboxService
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
string? prevOutboundTag = null; string? prevOutboundTag = null;
if (prevNode is not null if (prevNode is not null
&& prevNode.ConfigType != EConfigType.Custom) && Global.SingboxSupportConfigType.Contains(prevNode.ConfigType))
{ {
prevOutboundTag = $"prev-{Global.ProxyTag}"; prevOutboundTag = $"prev-{Global.ProxyTag}";
var prevServer = await GenServer(prevNode); var prevServer = await GenServer(prevNode);
@ -463,7 +463,7 @@ public partial class CoreConfigSingboxService
{ {
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
if (prevNode is not null if (prevNode is not null
&& prevNode.ConfigType != EConfigType.Custom) && Global.SingboxSupportConfigType.Contains(prevNode.ConfigType))
{ {
var prevOutbound = JsonUtils.Deserialize<Outbound4Sbox>(txtOutbound); var prevOutbound = JsonUtils.Deserialize<Outbound4Sbox>(txtOutbound);
await GenOutbound(prevNode, prevOutbound); await GenOutbound(prevNode, prevOutbound);
@ -558,7 +558,7 @@ public partial class CoreConfigSingboxService
// Next proxy // Next proxy
var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile); var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
if (nextNode is not null if (nextNode is not null
&& nextNode.ConfigType != EConfigType.Custom) && Global.SingboxSupportConfigType.Contains(nextNode.ConfigType))
{ {
nextOutbound ??= await GenServer(nextNode); nextOutbound ??= await GenServer(nextNode);
nextOutbound.tag = outbound.tag; nextOutbound.tag = outbound.tag;

View file

@ -338,7 +338,7 @@ public partial class CoreConfigSingboxService
var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag); var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag);
if (node == null if (node == null
|| node.ConfigType == EConfigType.Custom) || !Global.SingboxSupportConfigType.Contains(node.ConfigType))
{ {
return Global.ProxyTag; return Global.ProxyTag;
} }

View file

@ -110,11 +110,7 @@ public partial class CoreConfigV2rayService(Config config)
var proxyProfiles = new List<ProfileItem>(); var proxyProfiles = new List<ProfileItem>();
foreach (var it in selecteds) foreach (var it in selecteds)
{ {
if (it.ConfigType == EConfigType.Custom) if (!Global.XraySupportConfigType.Contains(it.ConfigType))
{
continue;
}
if (it.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.Anytls)
{ {
continue; continue;
} }
@ -250,7 +246,7 @@ public partial class CoreConfigV2rayService(Config config)
foreach (var it in selecteds) foreach (var it in selecteds)
{ {
if (it.ConfigType == EConfigType.Custom) if (!Global.XraySupportConfigType.Contains(it.ConfigType))
{ {
continue; continue;
} }

View file

@ -188,7 +188,7 @@ public partial class CoreConfigV2rayService
{ {
var profileNode = await AppManager.Instance.GetProfileItemViaRemarks(profile); var profileNode = await AppManager.Instance.GetProfileItemViaRemarks(profile);
if (profileNode is not null && if (profileNode is not null &&
profileNode.ConfigType is not (EConfigType.Custom or EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.Anytls) && Global.XraySupportConfigType.Contains(profileNode.ConfigType) &&
Utils.IsDomain(profileNode.Address)) Utils.IsDomain(profileNode.Address))
{ {
directDomainList.Add(profileNode.Address); directDomainList.Add(profileNode.Address);
@ -391,9 +391,7 @@ public partial class CoreConfigV2rayService
// Previous proxy // Previous proxy
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
if (prevNode is not null if (prevNode is not null
&& prevNode.ConfigType != EConfigType.Custom && Global.SingboxSupportConfigType.Contains(prevNode.ConfigType)
&& prevNode.ConfigType != EConfigType.Hysteria2
&& prevNode.ConfigType != EConfigType.TUIC
&& Utils.IsDomain(prevNode.Address)) && Utils.IsDomain(prevNode.Address))
{ {
domainList.Add(prevNode.Address); domainList.Add(prevNode.Address);
@ -402,9 +400,7 @@ public partial class CoreConfigV2rayService
// Next proxy // Next proxy
var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile); var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
if (nextNode is not null if (nextNode is not null
&& nextNode.ConfigType != EConfigType.Custom && Global.SingboxSupportConfigType.Contains(nextNode.ConfigType)
&& nextNode.ConfigType != EConfigType.Hysteria2
&& nextNode.ConfigType != EConfigType.TUIC
&& Utils.IsDomain(nextNode.Address)) && Utils.IsDomain(nextNode.Address))
{ {
domainList.Add(nextNode.Address); domainList.Add(nextNode.Address);

View file

@ -529,10 +529,7 @@ public partial class CoreConfigV2rayService
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
string? prevOutboundTag = null; string? prevOutboundTag = null;
if (prevNode is not null if (prevNode is not null
&& prevNode.ConfigType != EConfigType.Custom && Global.XraySupportConfigType.Contains(prevNode.ConfigType))
&& prevNode.ConfigType != EConfigType.Hysteria2
&& prevNode.ConfigType != EConfigType.TUIC
&& prevNode.ConfigType != EConfigType.Anytls)
{ {
var prevOutbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound); var prevOutbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound);
await GenOutbound(prevNode, prevOutbound); await GenOutbound(prevNode, prevOutbound);
@ -605,10 +602,7 @@ public partial class CoreConfigV2rayService
{ {
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
if (prevNode is not null if (prevNode is not null
&& prevNode.ConfigType != EConfigType.Custom && Global.XraySupportConfigType.Contains(prevNode.ConfigType))
&& prevNode.ConfigType != EConfigType.Hysteria2
&& prevNode.ConfigType != EConfigType.TUIC
&& prevNode.ConfigType != EConfigType.Anytls)
{ {
var prevOutbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound); var prevOutbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound);
await GenOutbound(prevNode, prevOutbound); await GenOutbound(prevNode, prevOutbound);
@ -675,10 +669,7 @@ public partial class CoreConfigV2rayService
// Next proxy // Next proxy
var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile); var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
if (nextNode is not null if (nextNode is not null
&& nextNode.ConfigType != EConfigType.Custom && Global.XraySupportConfigType.Contains(nextNode.ConfigType))
&& nextNode.ConfigType != EConfigType.Hysteria2
&& nextNode.ConfigType != EConfigType.TUIC
&& nextNode.ConfigType != EConfigType.Anytls)
{ {
if (nextOutbound == null) if (nextOutbound == null)
{ {

View file

@ -126,10 +126,7 @@ public partial class CoreConfigV2rayService
var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag); var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag);
if (node == null if (node == null
|| node.ConfigType == EConfigType.Custom || !Global.XraySupportConfigType.Contains(node.ConfigType))
|| node.ConfigType == EConfigType.Hysteria2
|| node.ConfigType == EConfigType.TUIC
|| node.ConfigType == EConfigType.Anytls)
{ {
return Global.ProxyTag; return Global.ProxyTag;
} }

View file

@ -356,8 +356,8 @@ public class SpeedtestService
private List<List<ServerTestItem>> GetTestBatchItem(List<ServerTestItem> lstSelected, int pageSize) private List<List<ServerTestItem>> GetTestBatchItem(List<ServerTestItem> lstSelected, int pageSize)
{ {
List<List<ServerTestItem>> lstTest = new(); List<List<ServerTestItem>> lstTest = new();
var lst1 = lstSelected.Where(t => t.ConfigType is not (EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.Anytls)).ToList(); var lst1 = lstSelected.Where(t => Global.XraySupportConfigType.Contains(t.ConfigType)).ToList();
var lst2 = lstSelected.Where(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.Anytls).ToList(); var lst2 = lstSelected.Where(t => Global.SingboxSupportConfigType.Contains(t.ConfigType) && !Global.XraySupportConfigType.Contains(t.ConfigType)).ToList();
for (var num = 0; num < (int)Math.Ceiling(lst1.Count * 1.0 / pageSize); num++) for (var num = 0; num < (int)Math.Ceiling(lst1.Count * 1.0 / pageSize); num++)
{ {