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".
This commit is contained in:
MHSanaei
2026-06-12 09:06:35 +02:00
parent bade1fcef6
commit d1a13844b2
+8 -1
View File
@@ -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) {