add fully function Multi User With ExpireDate & Traffic

This commit is contained in:
Hossin Asaadi
2022-11-12 08:25:29 -05:00
parent 77d24fbede
commit 47a48316ca
10 changed files with 166 additions and 53 deletions

View File

@@ -8,6 +8,7 @@ import (
"os"
"path"
"x-ui/config"
"x-ui/xray"
"x-ui/database/model"
)
@@ -43,6 +44,9 @@ func initSetting() error {
func initInboundClientIps() error {
return db.AutoMigrate(&model.InboundClientIps{})
}
func initClientTraffic() error {
return db.AutoMigrate(&xray.ClientTraffic{})
}
func InitDB(dbPath string) error {
dir := path.Dir(dbPath)
@@ -83,7 +87,11 @@ func InitDB(dbPath string) error {
if err != nil {
return err
}
err = initClientTraffic()
if err != nil {
return err
}
return nil
}

View File

@@ -32,7 +32,7 @@ type Inbound struct {
Remark string `json:"remark" form:"remark"`
Enable bool `json:"enable" form:"enable"`
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
ClientStats string `json:"clientStats" form:"clientStats"`
ClientStats []xray.ClientTraffic `gorm:"foreignKey:InboundId;references:Id" json:"clientStats" form:"clientStats"`
// config part
Listen string `json:"listen" form:"listen"`
@@ -76,6 +76,6 @@ type Client struct {
Email string `json:"email"`
LimitIP int `json:"limitIp"`
Security string `json:"security"`
Total int64 `json:"total" form:"total"`
TotalGB int64 `json:"totalGB" form:"totalGB"`
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
}