mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 05:04:22 +00:00
inbounds.tag was globally UNIQUE which prevents two remote nodes from having inbounds on the same port. client_traffics.email was globally UNIQUE which causes transaction rollback when different nodes have clients with the same email. Changed both to composite unique indexes scoped by their parent ((node_id, tag) and (inbound_id, email)). tagExists() is now node-aware so UI tag generation doesn't see remote node tags as conflicts. Adds migrateLegacyUniqueConstraints() to drop old constraints on startup.
19 lines
1 KiB
Go
19 lines
1 KiB
Go
package xray
|
|
|
|
// ClientTraffic represents traffic statistics and limits for a specific client.
|
|
// It tracks upload/download usage, expiry times, and online status for inbound clients.
|
|
type ClientTraffic struct {
|
|
Id int `json:"id" form:"id" gorm:"primaryKey;autoIncrement"`
|
|
InboundId int `json:"inboundId" form:"inboundId" gorm:"uniqueIndex:idx_ct_inbound_email,priority:1"`
|
|
Enable bool `json:"enable" form:"enable"`
|
|
Email string `json:"email" form:"email" gorm:"uniqueIndex:idx_ct_inbound_email,priority:2"`
|
|
UUID string `json:"uuid" form:"uuid" gorm:"-"`
|
|
SubId string `json:"subId" form:"subId" gorm:"-"`
|
|
Up int64 `json:"up" form:"up"`
|
|
Down int64 `json:"down" form:"down"`
|
|
AllTime int64 `json:"allTime" form:"allTime"`
|
|
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
|
|
Total int64 `json:"total" form:"total"`
|
|
Reset int `json:"reset" form:"reset" gorm:"default:0"`
|
|
LastOnline int64 `json:"lastOnline" form:"lastOnline" gorm:"default:0"`
|
|
}
|