Adjust chained proxy, actual outbound is at the top

Based on actual network flow instead of data packets
This commit is contained in:
DHR60 2025-09-14 13:23:13 +08:00
parent 826f9f833a
commit 63bf68376f
2 changed files with 10 additions and 6 deletions

View file

@ -682,11 +682,13 @@ public partial class CoreConfigSingboxService
private async Task<int> GenChainOutboundsList(List<ProfileItem> nodes, SingboxConfig singboxConfig, string baseTagName = Global.ProxyTag)
{
// Based on actual network flow instead of data packets
var nodesReverse = nodes.AsEnumerable().Reverse().ToList();
var resultOutbounds = new List<Outbound4Sbox>();
var resultEndpoints = new List<Endpoints4Sbox>(); // For endpoints
for (var i = 0; i < nodes.Count; i++)
for (var i = 0; i < nodesReverse.Count; i++)
{
var node = nodes[i];
var node = nodesReverse[i];
var server = await GenServer(node);
if (server is null)
@ -703,7 +705,7 @@ public partial class CoreConfigSingboxService
server.tag = baseTagName + i.ToString();
}
if (i != nodes.Count - 1)
if (i != nodesReverse.Count - 1)
{
server.detour = baseTagName + (i + 1).ToString();
}

View file

@ -749,10 +749,12 @@ public partial class CoreConfigV2rayService
private async Task<int> GenChainOutboundsList(List<ProfileItem> nodes, V2rayConfig v2RayConfig, string baseTagName = Global.ProxyTag)
{
// Based on actual network flow instead of data packets
var nodesReverse = nodes.AsEnumerable().Reverse().ToList();
var resultOutbounds = new List<Outbounds4Ray>();
for (var i = 0; i < nodes.Count; i++)
for (var i = 0; i < nodesReverse.Count; i++)
{
var node = nodes[i];
var node = nodesReverse[i];
var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
if (txtOutbound.IsNullOrEmpty())
{
@ -776,7 +778,7 @@ public partial class CoreConfigV2rayService
outbound.tag = "chain-" + baseTagName + i.ToString();
}
if (i != nodes.Count - 1)
if (i != nodesReverse.Count - 1)
{
outbound.streamSettings.sockopt = new()
{