mirror of
https://github.com/2dust/v2rayN.git
synced 2026-03-06 08:03:18 +00:00
Compare commits
3 commits
891d8341ac
...
f9c0b03490
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9c0b03490 | ||
|
|
931a124f04 | ||
|
|
d7e7bfd993 |
3 changed files with 23 additions and 40 deletions
|
|
@ -1233,19 +1233,28 @@ public static class ConfigHandler
|
||||||
/// <returns>A SOCKS profile item or null if not needed</returns>
|
/// <returns>A SOCKS profile item or null if not needed</returns>
|
||||||
public static ProfileItem? GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType)
|
public static ProfileItem? GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType)
|
||||||
{
|
{
|
||||||
if (node.ConfigType != EConfigType.Custom || !(node.PreSocksPort > 0))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ProfileItem? itemSocks = null;
|
ProfileItem? itemSocks = null;
|
||||||
var preCoreType = AppManager.Instance.RunningCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
|
if (node.ConfigType != EConfigType.Custom && coreType != ECoreType.sing_box && config.TunModeItem.EnableTun)
|
||||||
itemSocks = new ProfileItem()
|
|
||||||
{
|
{
|
||||||
CoreType = preCoreType,
|
itemSocks = new ProfileItem()
|
||||||
ConfigType = EConfigType.SOCKS,
|
{
|
||||||
Address = Global.Loopback,
|
CoreType = ECoreType.sing_box,
|
||||||
Port = node.PreSocksPort.Value,
|
ConfigType = EConfigType.SOCKS,
|
||||||
};
|
Address = Global.Loopback,
|
||||||
|
Port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0)
|
||||||
|
{
|
||||||
|
var preCoreType = AppManager.Instance.RunningCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
|
||||||
|
itemSocks = new ProfileItem()
|
||||||
|
{
|
||||||
|
CoreType = preCoreType,
|
||||||
|
ConfigType = EConfigType.SOCKS,
|
||||||
|
Address = Global.Loopback,
|
||||||
|
Port = node.PreSocksPort.Value,
|
||||||
|
};
|
||||||
|
}
|
||||||
return itemSocks;
|
return itemSocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,8 +171,7 @@ public static class CoreConfigHandler
|
||||||
var ruleOutboundNode = await AppManager.Instance.GetProfileItemViaRemarks(ruleItem.OutboundTag);
|
var ruleOutboundNode = await AppManager.Instance.GetProfileItemViaRemarks(ruleItem.OutboundTag);
|
||||||
if (ruleOutboundNode != null)
|
if (ruleOutboundNode != null)
|
||||||
{
|
{
|
||||||
var ruleOutboundNodeAct = await FillNodeContext(context, ruleOutboundNode, false);
|
await FillNodeContext(context, ruleOutboundNode);
|
||||||
context.AllProxiesMap[$"remark:{ruleItem.OutboundTag}"] = ruleOutboundNodeAct;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,34 +96,9 @@ public class GroupProfileManager
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var childProfileIds = Utils.String2List(extra.ChildItems)
|
var childProfileIds = Utils.String2List(extra.ChildItems)
|
||||||
?.Where(p => !string.IsNullOrEmpty(p))
|
?.Where(p => !string.IsNullOrEmpty(p)) ?? [];
|
||||||
.ToList() ?? [];
|
|
||||||
if (childProfileIds.Count == 0)
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
var childProfiles = await AppManager.Instance.GetProfileItemsByIndexIds(childProfileIds);
|
var childProfiles = await AppManager.Instance.GetProfileItemsByIndexIds(childProfileIds);
|
||||||
if (childProfiles == null || childProfiles.Count == 0)
|
return childProfiles ?? [];
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
var profileMap = childProfiles
|
|
||||||
.Where(p => p != null && !p.IndexId.IsNullOrEmpty())
|
|
||||||
.GroupBy(p => p!.IndexId!)
|
|
||||||
.ToDictionary(g => g.Key, g => g.First());
|
|
||||||
|
|
||||||
var ordered = new List<ProfileItem>(childProfileIds.Count);
|
|
||||||
foreach (var id in childProfileIds)
|
|
||||||
{
|
|
||||||
if (id != null && profileMap.TryGetValue(id, out var item) && item != null)
|
|
||||||
{
|
|
||||||
ordered.Add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ordered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<List<ProfileItem>> GetSubChildProfileItems(ProtocolExtraItem? extra)
|
private static async Task<List<ProfileItem>> GetSubChildProfileItems(ProtocolExtraItem? extra)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue