mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 05:03:02 +00:00
Respect user-set core type
This commit is contained in:
parent
67c4ae02ba
commit
23a04e9308
4 changed files with 13 additions and 9 deletions
|
|
@ -94,11 +94,9 @@ public static class CoreConfigHandler
|
||||||
{
|
{
|
||||||
var result = new RetResult();
|
var result = new RetResult();
|
||||||
var context = await BuildCoreConfigContext(config, new());
|
var context = await BuildCoreConfigContext(config, new());
|
||||||
var ids = selecteds.Where(serverTestItem => !serverTestItem.IndexId.IsNullOrEmpty())
|
foreach (var testItem in selecteds)
|
||||||
.Select(serverTestItem => serverTestItem.IndexId);
|
|
||||||
var nodes = await AppManager.Instance.GetProfileItemsByIndexIds(ids);
|
|
||||||
foreach (var node in nodes)
|
|
||||||
{
|
{
|
||||||
|
var node = testItem.Profile;
|
||||||
var actNode = await FillNodeContext(context, node, true);
|
var actNode = await FillNodeContext(context, node, true);
|
||||||
if (node.IndexId == actNode.IndexId)
|
if (node.IndexId == actNode.IndexId)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ public class CoreManager
|
||||||
|
|
||||||
public async Task<ProcessService?> LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
|
public async Task<ProcessService?> LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
|
||||||
{
|
{
|
||||||
var coreType = selecteds.Any(t => Global.SingboxOnlyConfigType.Contains(t.ConfigType)) ? ECoreType.sing_box : ECoreType.Xray;
|
var coreType = selecteds.FirstOrDefault()?.CoreType == ECoreType.sing_box ? ECoreType.sing_box : ECoreType.Xray;
|
||||||
var fileName = string.Format(Global.CoreSpeedtestConfigFileName, Utils.GetGuid(false));
|
var fileName = string.Format(Global.CoreSpeedtestConfigFileName, Utils.GetGuid(false));
|
||||||
var configPath = Utils.GetBinConfigPath(fileName);
|
var configPath = Utils.GetBinConfigPath(fileName);
|
||||||
var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType);
|
var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType);
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,6 @@ public class ServerTestItem
|
||||||
public EConfigType ConfigType { get; set; }
|
public EConfigType ConfigType { get; set; }
|
||||||
public bool AllowTest { get; set; }
|
public bool AllowTest { get; set; }
|
||||||
public int QueueNum { get; set; }
|
public int QueueNum { get; set; }
|
||||||
|
public required ProfileItem Profile { get; set; }
|
||||||
|
public ECoreType CoreType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,9 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
private async Task<List<ServerTestItem>> GetClearItem(ESpeedActionType actionType, List<ProfileItem> selecteds)
|
private async Task<List<ServerTestItem>> GetClearItem(ESpeedActionType actionType, List<ProfileItem> selecteds)
|
||||||
{
|
{
|
||||||
var lstSelected = new List<ServerTestItem>();
|
var lstSelected = new List<ServerTestItem>();
|
||||||
foreach (var it in selecteds)
|
for (var i = 0; i < selecteds.Count; i++)
|
||||||
{
|
{
|
||||||
|
var it = selecteds[i];
|
||||||
if (it.ConfigType.IsComplexType())
|
if (it.ConfigType.IsComplexType())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -74,13 +75,16 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var profile = await AppManager.Instance.GetProfileItem(it.IndexId) ?? it;
|
||||||
lstSelected.Add(new ServerTestItem()
|
lstSelected.Add(new ServerTestItem()
|
||||||
{
|
{
|
||||||
IndexId = it.IndexId,
|
IndexId = it.IndexId,
|
||||||
Address = it.Address,
|
Address = it.Address,
|
||||||
Port = it.Port,
|
Port = it.Port,
|
||||||
ConfigType = it.ConfigType,
|
ConfigType = it.ConfigType,
|
||||||
QueueNum = selecteds.IndexOf(it)
|
QueueNum = i,
|
||||||
|
Profile = profile,
|
||||||
|
CoreType = AppManager.Instance.GetCoreType(profile, it.ConfigType),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -353,8 +357,8 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
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 => Global.XraySupportConfigType.Contains(t.ConfigType)).ToList();
|
var lst1 = lstSelected.Where(t => Global.XraySupportConfigType.Contains(t.ConfigType) && t.CoreType == ECoreType.Xray).ToList();
|
||||||
var lst2 = lstSelected.Where(t => Global.SingboxOnlyConfigType.Contains(t.ConfigType)).ToList();
|
var lst2 = lstSelected.Where(t => Global.SingboxSupportConfigType.Contains(t.ConfigType) && t.CoreType == ECoreType.sing_box).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