mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 20:09:12 +00:00
Adds Xray and Singbox config type support
This commit is contained in:
parent
8e177a9851
commit
ade4cbcf80
5 changed files with 55 additions and 43 deletions
|
@ -330,6 +330,31 @@ public class Global
|
||||||
EConfigType.SOCKS,
|
EConfigType.SOCKS,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
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",
|
||||||
|
|
|
@ -27,10 +27,16 @@ public class CoreConfigHandler
|
||||||
{
|
{
|
||||||
result = await new CoreConfigSingboxService(config).GenerateClientConfigContent(node);
|
result = await new CoreConfigSingboxService(config).GenerateClientConfigContent(node);
|
||||||
}
|
}
|
||||||
else
|
else if (AppHandler.Instance.GetCoreType(node, node.ConfigType) == ECoreType.Xray)
|
||||||
{
|
{
|
||||||
result = await new CoreConfigV2rayService(config).GenerateClientConfigContent(node);
|
result = await new CoreConfigV2rayService(config).GenerateClientConfigContent(node);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Msg = ResUI.OperationFailed;
|
||||||
|
result.Success = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
if (result.Success != true)
|
if (result.Success != true)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
@ -142,7 +143,7 @@ public class CoreConfigSingboxService
|
||||||
|
|
||||||
foreach (var it in selecteds)
|
foreach (var it in selecteds)
|
||||||
{
|
{
|
||||||
if (it.ConfigType == EConfigType.Custom)
|
if (!Global.SingboxSupportConfigType.Contains(it.ConfigType))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +379,7 @@ public class CoreConfigSingboxService
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -1117,7 +1118,7 @@ public class CoreConfigSingboxService
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppHandler.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);
|
||||||
|
@ -1208,7 +1209,7 @@ public class CoreConfigSingboxService
|
||||||
{
|
{
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppHandler.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);
|
||||||
|
@ -1315,7 +1316,7 @@ public class CoreConfigSingboxService
|
||||||
// Next proxy
|
// Next proxy
|
||||||
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
var nextNode = await AppHandler.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;
|
||||||
|
@ -1652,7 +1653,7 @@ public class CoreConfigSingboxService
|
||||||
|
|
||||||
var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag);
|
var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag);
|
||||||
if (node == null
|
if (node == null
|
||||||
|| node.ConfigType == EConfigType.Custom)
|
|| !Global.SingboxSupportConfigType.Contains(node.ConfigType))
|
||||||
{
|
{
|
||||||
return Global.ProxyTag;
|
return Global.ProxyTag;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
@ -116,11 +117,7 @@ public class CoreConfigV2rayService
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +252,7 @@ public class CoreConfigV2rayService
|
||||||
|
|
||||||
foreach (var it in selecteds)
|
foreach (var it in selecteds)
|
||||||
{
|
{
|
||||||
if (it.ConfigType == EConfigType.Custom)
|
if (!Global.SingboxSupportConfigType.Contains(it.ConfigType))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -707,10 +704,7 @@ public class CoreConfigV2rayService
|
||||||
|
|
||||||
var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag);
|
var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag);
|
||||||
if (node == null
|
if (node == null
|
||||||
|| node.ConfigType == EConfigType.Custom
|
|| !Global.SingboxSupportConfigType.Contains(node.ConfigType))
|
||||||
|| node.ConfigType == EConfigType.Hysteria2
|
|
||||||
|| node.ConfigType == EConfigType.TUIC
|
|
||||||
|| node.ConfigType == EConfigType.Anytls)
|
|
||||||
{
|
{
|
||||||
return Global.ProxyTag;
|
return Global.ProxyTag;
|
||||||
}
|
}
|
||||||
|
@ -1289,10 +1283,7 @@ public class CoreConfigV2rayService
|
||||||
// Previous proxy
|
// Previous proxy
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppHandler.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
|
|
||||||
&& prevNode.ConfigType != EConfigType.Anytls
|
|
||||||
&& Utils.IsDomain(prevNode.Address))
|
&& Utils.IsDomain(prevNode.Address))
|
||||||
{
|
{
|
||||||
domainList.Add(prevNode.Address);
|
domainList.Add(prevNode.Address);
|
||||||
|
@ -1301,10 +1292,7 @@ public class CoreConfigV2rayService
|
||||||
// Next proxy
|
// Next proxy
|
||||||
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
var nextNode = await AppHandler.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
|
|
||||||
&& nextNode.ConfigType != EConfigType.Anytls
|
|
||||||
&& Utils.IsDomain(nextNode.Address))
|
&& Utils.IsDomain(nextNode.Address))
|
||||||
{
|
{
|
||||||
domainList.Add(nextNode.Address);
|
domainList.Add(nextNode.Address);
|
||||||
|
@ -1420,10 +1408,7 @@ public class CoreConfigV2rayService
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppHandler.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);
|
||||||
|
@ -1496,10 +1481,7 @@ public class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppHandler.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);
|
||||||
|
@ -1566,10 +1548,7 @@ public class CoreConfigV2rayService
|
||||||
// Next proxy
|
// Next proxy
|
||||||
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
var nextNode = await AppHandler.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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ public class SpeedtestService
|
||||||
var lstSelected = new List<ServerTestItem>();
|
var lstSelected = new List<ServerTestItem>();
|
||||||
foreach (var it in selecteds)
|
foreach (var it in selecteds)
|
||||||
{
|
{
|
||||||
if (it.ConfigType == EConfigType.Custom)
|
if (!(Global.XraySupportConfigType.Contains(it.ConfigType) || Global.SingboxSupportConfigType.Contains(it.ConfigType)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +123,7 @@ public class SpeedtestService
|
||||||
List<Task> tasks = [];
|
List<Task> tasks = [];
|
||||||
foreach (var it in selecteds)
|
foreach (var it in selecteds)
|
||||||
{
|
{
|
||||||
if (it.ConfigType == EConfigType.Custom)
|
if (!(Global.XraySupportConfigType.Contains(it.ConfigType) || Global.SingboxSupportConfigType.Contains(it.ConfigType)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +208,7 @@ public class SpeedtestService
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it.ConfigType == EConfigType.Custom)
|
if (!(Global.XraySupportConfigType.Contains(it.ConfigType) || Global.SingboxSupportConfigType.Contains(it.ConfigType)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -244,7 +245,7 @@ public class SpeedtestService
|
||||||
UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
|
UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it.ConfigType == EConfigType.Custom)
|
if (!(Global.XraySupportConfigType.Contains(it.ConfigType) || Global.SingboxSupportConfigType.Contains(it.ConfigType)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -358,8 +359,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++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue