mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-31 07:27:13 +00:00
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:
@@ -118,7 +118,14 @@ func (a *ClientController) get(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
rec.Flow = flow
|
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) {
|
func (a *ClientController) create(c *gin.Context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user