mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 21:23:04 +00:00
Fix
This commit is contained in:
parent
437ba09d06
commit
c6dd26e324
2 changed files with 55 additions and 10 deletions
|
|
@ -519,7 +519,7 @@ public partial class CoreConfigSingboxService
|
|||
var outUrltest = new Outbound4Sbox
|
||||
{
|
||||
type = "urltest",
|
||||
tag = $"{Global.ProxyTag}-auto",
|
||||
tag = $"{baseTagName}-auto",
|
||||
outbounds = proxyTags,
|
||||
interrupt_exist_connections = false,
|
||||
};
|
||||
|
|
@ -533,7 +533,7 @@ public partial class CoreConfigSingboxService
|
|||
var outSelector = new Outbound4Sbox
|
||||
{
|
||||
type = "selector",
|
||||
tag = Global.ProxyTag,
|
||||
tag = baseTagName,
|
||||
outbounds = JsonUtils.DeepCopy(proxyTags),
|
||||
interrupt_exist_connections = false,
|
||||
};
|
||||
|
|
@ -613,22 +613,30 @@ public partial class CoreConfigSingboxService
|
|||
}
|
||||
else if (chainStartNodes.Count > 1)
|
||||
{
|
||||
var existedChainNodes = JsonUtils.DeepCopy(resultOutbounds);
|
||||
var existedChainNodes = CloneOutbounds(resultOutbounds);
|
||||
resultOutbounds.Clear();
|
||||
var j = 0;
|
||||
foreach (var chainStartNode in chainStartNodes)
|
||||
{
|
||||
var existedChainNodesClone = JsonUtils.DeepCopy(existedChainNodes);
|
||||
for (var j = 0; j < existedChainNodesClone.Count; j++)
|
||||
var existedChainNodesClone = CloneOutbounds(existedChainNodes);
|
||||
foreach (var existedChainNode in existedChainNodesClone)
|
||||
{
|
||||
var existedChainNode = existedChainNodesClone[j];
|
||||
var cloneTag = $"{existedChainNode.tag}-clone-{j + 1}";
|
||||
existedChainNode.tag = cloneTag;
|
||||
}
|
||||
for (var k = 0; k < existedChainNodesClone.Count; k++)
|
||||
{
|
||||
var existedChainNode = existedChainNodesClone[k];
|
||||
var previousDialerProxyTag = existedChainNode.detour;
|
||||
var nextTag = k + 1 < existedChainNodesClone.Count
|
||||
? existedChainNodesClone[k + 1].tag
|
||||
: chainStartNode.tag;
|
||||
existedChainNode.detour = (previousDialerProxyTag == currentTag)
|
||||
? chainStartNode.tag
|
||||
: existedChainNodesClone[j + 1].tag;
|
||||
: nextTag;
|
||||
resultOutbounds.Add(existedChainNode);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -649,6 +657,33 @@ public partial class CoreConfigSingboxService
|
|||
return resultOutbounds;
|
||||
}
|
||||
|
||||
private static List<BaseServer4Sbox> CloneOutbounds(List<BaseServer4Sbox> source)
|
||||
{
|
||||
if (source is null || source.Count == 0)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var result = new List<BaseServer4Sbox>(source.Count);
|
||||
foreach (var item in source)
|
||||
{
|
||||
BaseServer4Sbox? clone = null;
|
||||
if (item is Outbound4Sbox outbound)
|
||||
{
|
||||
clone = JsonUtils.DeepCopy(outbound);
|
||||
}
|
||||
else if (item is Endpoints4Sbox endpoint)
|
||||
{
|
||||
clone = JsonUtils.DeepCopy(endpoint);
|
||||
}
|
||||
if (clone is not null)
|
||||
{
|
||||
result.Add(clone);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void FillRangeProxy(List<BaseServer4Sbox> servers, SingboxConfig singboxConfig, bool prepend = true)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -757,21 +757,31 @@ public partial class CoreConfigV2rayService
|
|||
{
|
||||
var existedChainNodes = JsonUtils.DeepCopy(resultOutbounds);
|
||||
resultOutbounds.Clear();
|
||||
var j = 0;
|
||||
foreach (var chainStartNode in chainStartNodes)
|
||||
{
|
||||
var existedChainNodesClone = JsonUtils.DeepCopy(existedChainNodes);
|
||||
for (var j = 0; j < existedChainNodesClone.Count; j++)
|
||||
foreach (var existedChainNode in existedChainNodesClone)
|
||||
{
|
||||
var existedChainNode = existedChainNodesClone[j];
|
||||
var cloneTag = $"{existedChainNode.tag}-clone-{j + 1}";
|
||||
existedChainNode.tag = cloneTag;
|
||||
}
|
||||
for (var k = 0; k < existedChainNodesClone.Count; k++)
|
||||
{
|
||||
var existedChainNode = existedChainNodesClone[k];
|
||||
var previousDialerProxyTag = existedChainNode.streamSettings?.sockopt?.dialerProxy;
|
||||
var nextTag = k + 1 < existedChainNodesClone.Count
|
||||
? existedChainNodesClone[k + 1].tag
|
||||
: chainStartNode.tag;
|
||||
existedChainNode.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = (previousDialerProxyTag == currentTag) ? chainStartNode.tag : existedChainNodesClone[j + 1].tag
|
||||
dialerProxy = (previousDialerProxyTag == currentTag)
|
||||
? chainStartNode.tag
|
||||
: nextTag
|
||||
};
|
||||
resultOutbounds.Add(existedChainNode);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue