From d1a13844b242ff4d36405d81cc3fdf384a5c505c Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 12 Jun 2026 09:06:35 +0200 Subject: [PATCH] feat(api): include consumed traffic in the client-get response (#4973) GET /panel/api/clients/get/:email returned the quota (totalGB) but not the bytes the client has actually used, forcing API consumers to scrape it elsewhere. Add a sibling "usedTraffic" field (up+down, including the cross-node global overlay) next to "client" and "inboundIds". --- internal/web/controller/client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/web/controller/client.go b/internal/web/controller/client.go index a362d7f78..f52c42a40 100644 --- a/internal/web/controller/client.go +++ b/internal/web/controller/client.go @@ -118,7 +118,14 @@ func (a *ClientController) get(c *gin.Context) { return } rec.Flow = flow - jsonObj(c, gin.H{"client": rec, "inboundIds": inboundIds}, nil) + // Consumed bytes (up+down, including cross-node global overlay) so API + // consumers can pair usage with the client's totalGB quota (#4973). + // Best-effort: a traffic lookup failure must not break the client fetch. + var usedTraffic int64 + if t, tErr := a.inboundService.GetClientTrafficByEmail(email); tErr == nil && t != nil { + usedTraffic = t.Up + t.Down + } + jsonObj(c, gin.H{"client": rec, "inboundIds": inboundIds, "usedTraffic": usedTraffic}, nil) } func (a *ClientController) create(c *gin.Context) {