3x-ui/xray/client_traffic.go

26 lines
1.4 KiB
Go
Raw Normal View History

2023-02-09 19:18:06 +00:00
package xray
2025-09-20 07:35:50 +00:00
// ClientTraffic represents traffic statistics and limits for a specific client.
// It tracks upload/download usage, expiry times, and online status for inbound clients.
2023-02-09 19:18:06 +00:00
type ClientTraffic struct {
2023-02-18 12:37:32 +00:00
Id int `json:"id" form:"id" gorm:"primaryKey;autoIncrement"`
InboundId int `json:"inboundId" form:"inboundId"`
2023-02-09 19:18:06 +00:00
Enable bool `json:"enable" form:"enable"`
Email string `json:"email" form:"email" gorm:"unique"`
2025-09-21 17:16:54 +00:00
UUID string `json:"uuid" form:"uuid" gorm:"-"`
SubId string `json:"subId" form:"subId" gorm:"-"`
2023-02-18 12:37:32 +00:00
Up int64 `json:"up" form:"up"`
Down int64 `json:"down" form:"down"`
AllTime int64 `json:"allTime" form:"allTime"`
2023-02-09 19:18:06 +00:00
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
Total int64 `json:"total" form:"total"`
2023-12-04 18:20:16 +00:00
Reset int `json:"reset" form:"reset" gorm:"default:0"`
LastOnline int64 `json:"lastOnline" form:"lastOnline" gorm:"default:0"`
// DailyTrafficModelExtension: Adds persistent fields for 24h cycle accounting (DailyUp/Down)
// and a timezone-aware reset checkpoint. Enables "lazy reset" logic during traffic updates,
// eliminating the need for background cron jobs or scheduled tasks.
DailyUp int64 `json:"dailyUp" form:"dailyUp"`
DailyDown int64 `json:"dailyDown" form:"dailyDown"`
LastDailyReset int64 `json:"lastDailyReset" form:"lastDailyReset" gorm:"default:0"`
2023-02-09 19:18:06 +00:00
}