mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-23 01:50:17 +08:00
register inter-chain profiles for traffic
This commit is contained in:
parent
77374c268b
commit
43fb62a672
File diff suppressed because it is too large
Load Diff
@ -61,6 +61,7 @@ message TestResp {
|
|||||||
message QueryStatsResp{
|
message QueryStatsResp{
|
||||||
map<string, int64> ups = 1;
|
map<string, int64> ups = 1;
|
||||||
map<string, int64> downs = 2;
|
map<string, int64> downs = 2;
|
||||||
|
repeated string intermediate_tags = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum UpdateAction {
|
enum UpdateAction {
|
||||||
|
|||||||
@ -189,33 +189,18 @@ func (s *server) QueryStats(ctx context.Context, _ *gen.EmptyReq) (*gen.QuerySta
|
|||||||
return nil, E.New("invalid clash server type")
|
return nil, E.New("invalid clash server type")
|
||||||
}
|
}
|
||||||
outbounds := service.FromContext[adapter.OutboundManager](boxInstance.Context())
|
outbounds := service.FromContext[adapter.OutboundManager](boxInstance.Context())
|
||||||
endpoints := service.FromContext[adapter.EndpointManager](boxInstance.Context())
|
|
||||||
if outbounds == nil {
|
if outbounds == nil {
|
||||||
log.Println("Failed to assert outbound manager")
|
log.Println("Failed to assert outbound manager")
|
||||||
return nil, E.New("invalid outbound manager type")
|
return nil, E.New("invalid outbound manager type")
|
||||||
}
|
}
|
||||||
if endpoints == nil {
|
|
||||||
log.Println("Failed to assert endpoint manager")
|
|
||||||
return nil, E.New("invalid endpoint manager type")
|
|
||||||
}
|
|
||||||
for _, out := range outbounds.Outbounds() {
|
for _, out := range outbounds.Outbounds() {
|
||||||
if len(out.Dependencies()) > 0 {
|
if len(out.Dependencies()) > 0 {
|
||||||
// ignore, has detour
|
resp.IntermediateTags = append(resp.IntermediateTags, out.Tag())
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
u, d := cApi.TrafficManager().TotalOutbound(out.Tag())
|
u, d := cApi.TrafficManager().TotalOutbound(out.Tag())
|
||||||
resp.Ups[out.Tag()] = u
|
resp.Ups[out.Tag()] = u
|
||||||
resp.Downs[out.Tag()] = d
|
resp.Downs[out.Tag()] = d
|
||||||
}
|
}
|
||||||
for _, end := range endpoints.Endpoints() {
|
|
||||||
if len(end.Dependencies()) > 0 {
|
|
||||||
// ignore, has detour
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
u, d := cApi.TrafficManager().TotalOutbound(end.Tag())
|
|
||||||
resp.Ups[end.Tag()] = u
|
|
||||||
resp.Downs[end.Tag()] = d
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,16 @@ namespace NekoGui_traffic {
|
|||||||
item->downlink += down;
|
item->downlink += down;
|
||||||
item->uplink_rate = up * 1000 / interval;
|
item->uplink_rate = up * 1000 / interval;
|
||||||
item->downlink_rate = down * 1000 / interval;
|
item->downlink_rate = down * 1000 / interval;
|
||||||
|
auto isInter = false;
|
||||||
|
for (const auto& inter_tag : resp.intermediate_tags())
|
||||||
|
{
|
||||||
|
if (inter_tag == item->tag)
|
||||||
|
{
|
||||||
|
isInter = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isInter) continue;
|
||||||
if (item->tag == "direct")
|
if (item->tag == "direct")
|
||||||
{
|
{
|
||||||
direct->uplink_rate = item->uplink_rate;
|
direct->uplink_rate = item->uplink_rate;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user