fix endpoint issues again

This commit is contained in:
Nova 2025-04-10 04:49:06 +03:30
parent c43d11cb7b
commit 570c187e7c
2 changed files with 13 additions and 4 deletions

View File

@ -186,14 +186,24 @@ func (s *server) QueryStats(ctx context.Context, _ *gen.EmptyReq) (*gen.QuerySta
}
outbounds := service.FromContext[adapter.OutboundManager](boxInstance.Context())
if outbounds == nil {
log.Println("Failed to assert outbound manager")
return nil, E.New("invalid outbound manager type")
log.Println("Failed to get outbound manager")
return nil, E.New("nil outbound manager")
}
endpoints := service.FromContext[adapter.EndpointManager](boxInstance.Context())
if endpoints == nil {
log.Println("Failed to get endpoint manager")
return nil, E.New("nil endpoint manager")
}
for _, out := range outbounds.Outbounds() {
u, d := cApi.TrafficManager().TotalOutbound(out.Tag())
resp.Ups[out.Tag()] = u
resp.Downs[out.Tag()] = d
}
for _, ep := range endpoints.Endpoints() {
u, d := cApi.TrafficManager().TotalOutbound(ep.Tag())
resp.Ups[ep.Tag()] = u
resp.Downs[ep.Tag()] = d
}
}
}

View File

@ -311,8 +311,7 @@ namespace NekoGui {
// Bypass Lookup for the first profile
auto serverAddress = ent->bean->serverAddress;
auto customBean = dynamic_cast<NekoGui_fmt::CustomBean *>(ent->bean.get());
if (customBean != nullptr && customBean->core == "internal") {
if (auto customBean = dynamic_cast<NekoGui_fmt::CustomBean *>(ent->bean.get()); customBean != nullptr && customBean->core == "internal") {
auto server = QString2QJsonObject(customBean->config_simple)["server"].toString();
if (!server.isEmpty()) serverAddress = server;
}