mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 13:13:04 +00:00
Fix chain
This commit is contained in:
parent
a89471da92
commit
3768e0d989
2 changed files with 48 additions and 25 deletions
|
|
@ -604,21 +604,31 @@ public partial class CoreConfigSingboxService
|
|||
if (i != 0)
|
||||
{
|
||||
var chainStartNodes = childProfiles.Where(n => n.tag.StartsWith(currentTag)).ToList();
|
||||
var existedChainNodes = JsonUtils.DeepCopy(resultOutbounds);
|
||||
resultOutbounds.Clear();
|
||||
foreach (var chainStartNode in chainStartNodes)
|
||||
if (chainStartNodes.Count == 1)
|
||||
{
|
||||
var existedChainNodesClone = JsonUtils.DeepCopy(existedChainNodes);
|
||||
for (var j = 0; j < existedChainNodesClone.Count; j++)
|
||||
foreach (var existedChainEndNode in resultOutbounds.Where(n => n.detour == currentTag))
|
||||
{
|
||||
var existedChainNode = existedChainNodesClone[j];
|
||||
var cloneTag = $"{existedChainNode.tag}-clone-{j + 1}";
|
||||
existedChainNode.tag = cloneTag;
|
||||
var previousDialerProxyTag = existedChainNode.detour;
|
||||
existedChainNode.detour = (previousDialerProxyTag == currentTag)
|
||||
? chainStartNode.tag
|
||||
: existedChainNodesClone[j + 1].tag;
|
||||
resultOutbounds.Add(existedChainNode);
|
||||
existedChainEndNode.detour = chainStartNodes.First().tag;
|
||||
}
|
||||
}
|
||||
else if (chainStartNodes.Count > 1)
|
||||
{
|
||||
var existedChainNodes = JsonUtils.DeepCopy(resultOutbounds);
|
||||
resultOutbounds.Clear();
|
||||
foreach (var chainStartNode in chainStartNodes)
|
||||
{
|
||||
var existedChainNodesClone = JsonUtils.DeepCopy(existedChainNodes);
|
||||
for (var j = 0; j < existedChainNodesClone.Count; j++)
|
||||
{
|
||||
var existedChainNode = existedChainNodesClone[j];
|
||||
var cloneTag = $"{existedChainNode.tag}-clone-{j + 1}";
|
||||
existedChainNode.tag = cloneTag;
|
||||
var previousDialerProxyTag = existedChainNode.detour;
|
||||
existedChainNode.detour = (previousDialerProxyTag == currentTag)
|
||||
? chainStartNode.tag
|
||||
: existedChainNodesClone[j + 1].tag;
|
||||
resultOutbounds.Add(existedChainNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -743,22 +743,35 @@ public partial class CoreConfigV2rayService
|
|||
if (i != 0)
|
||||
{
|
||||
var chainStartNodes = childProfiles.Where(n => n.tag.StartsWith(currentTag)).ToList();
|
||||
var existedChainNodes = JsonUtils.DeepCopy(resultOutbounds);
|
||||
resultOutbounds.Clear();
|
||||
foreach (var chainStartNode in chainStartNodes)
|
||||
if (chainStartNodes.Count == 1)
|
||||
{
|
||||
var existedChainNodesClone = JsonUtils.DeepCopy(existedChainNodes);
|
||||
for (var j = 0; j < existedChainNodesClone.Count; j++)
|
||||
foreach (var existedChainEndNode in resultOutbounds.Where(n => n.streamSettings?.sockopt?.dialerProxy == currentTag))
|
||||
{
|
||||
var existedChainNode = existedChainNodesClone[j];
|
||||
var cloneTag = $"{existedChainNode.tag}-clone-{j + 1}";
|
||||
existedChainNode.tag = cloneTag;
|
||||
var previousDialerProxyTag = existedChainNode.streamSettings?.sockopt?.dialerProxy;
|
||||
existedChainNode.streamSettings.sockopt = new()
|
||||
existedChainEndNode.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = (previousDialerProxyTag == currentTag) ? chainStartNode.tag : existedChainNodesClone[j + 1].tag
|
||||
dialerProxy = chainStartNodes.First().tag
|
||||
};
|
||||
resultOutbounds.Add(existedChainNode);
|
||||
}
|
||||
}
|
||||
else if (chainStartNodes.Count > 1)
|
||||
{
|
||||
var existedChainNodes = JsonUtils.DeepCopy(resultOutbounds);
|
||||
resultOutbounds.Clear();
|
||||
foreach (var chainStartNode in chainStartNodes)
|
||||
{
|
||||
var existedChainNodesClone = JsonUtils.DeepCopy(existedChainNodes);
|
||||
for (var j = 0; j < existedChainNodesClone.Count; j++)
|
||||
{
|
||||
var existedChainNode = existedChainNodesClone[j];
|
||||
var cloneTag = $"{existedChainNode.tag}-clone-{j + 1}";
|
||||
existedChainNode.tag = cloneTag;
|
||||
var previousDialerProxyTag = existedChainNode.streamSettings?.sockopt?.dialerProxy;
|
||||
existedChainNode.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = (previousDialerProxyTag == currentTag) ? chainStartNode.tag : existedChainNodesClone[j + 1].tag
|
||||
};
|
||||
resultOutbounds.Add(existedChainNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue