From 120ca0a4009d978d841398f2bfb7a81ce9e0c8d0 Mon Sep 17 00:00:00 2001 From: OnceUponATimeInAmerica Date: Thu, 13 Jun 2024 23:14:40 +0330 Subject: [PATCH] Extend stats reporting to support custom configs with several load-balanced outbounds in them, with tags starting with "proxy" e.g. proxy1, proxy2 (fully compatible with existing configs) --- v2rayN/v2rayN/Handler/StatisticsV2ray.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/v2rayN/v2rayN/Handler/StatisticsV2ray.cs b/v2rayN/v2rayN/Handler/StatisticsV2ray.cs index 67385453ec..0be8a61728 100644 --- a/v2rayN/v2rayN/Handler/StatisticsV2ray.cs +++ b/v2rayN/v2rayN/Handler/StatisticsV2ray.cs @@ -87,6 +87,8 @@ private async void Run() private void ParseOutput(Google.Protobuf.Collections.RepeatedField source, out ServerSpeedItem server) { server = new(); + long aggregateProxyUp = 0; + long aggregateProxyDown = 0; try { foreach (Stat stat in source) @@ -101,15 +103,15 @@ private void ParseOutput(Google.Protobuf.Collections.RepeatedField source, name = nStr[1]; type = nStr[3]; - if (name == Global.ProxyTag) + if (name.StartsWith(Global.ProxyTag)) { if (type == "uplink") { - server.proxyUp = value; + aggregateProxyUp += value; } else if (type == "downlink") { - server.proxyDown = value; + aggregateProxyDown += value; } } else if (name == Global.DirectTag) @@ -124,6 +126,8 @@ private void ParseOutput(Google.Protobuf.Collections.RepeatedField source, } } } + server.proxyUp = aggregateProxyUp; + server.proxyDown = aggregateProxyDown; } catch {