Compare commits

...

4 Commits
0.5.1 ... 0.5.2

Author SHA1 Message Date
Alireza Ahmadi
80f052697c v0.5.2 2023-04-13 16:59:01 +02:00
Alireza Ahmadi
fb15248030 [migration] Remove Orphaned Traffics 2023-04-13 16:31:35 +02:00
Alireza Ahmadi
6a18ba48aa remove traffics of edited emails 2023-04-13 16:30:39 +02:00
Alireza Ahmadi
c13b7b2a18 [backup] fix db name in we request 2023-04-13 14:13:04 +02:00
4 changed files with 17 additions and 5 deletions

View File

@@ -1 +1 @@
0.5.1
0.5.2

View File

@@ -137,7 +137,7 @@ func (a *ServerController) getDb(c *gin.Context) {
}
// Set the headers for the response
c.Header("Content-Type", "application/octet-stream")
c.Header("Content-Disposition", "attachment; filename=xui.db")
c.Header("Content-Disposition", "attachment; filename=x-ui.db")
// Write the file contents to the response
c.Writer.Write(db)

View File

@@ -405,7 +405,7 @@ func (s *InboundService) adjustTraffics(traffics []*xray.ClientTraffic) (full_tr
}
}()
for traffic_index, traffic := range traffics {
for _, traffic := range traffics {
inbound := &model.Inbound{}
client_traffic := &xray.ClientTraffic{}
err := db.Model(xray.ClientTraffic{}).Where("email = ?", traffic.Email).First(client_traffic).Error
@@ -464,9 +464,9 @@ func (s *InboundService) adjustTraffics(traffics []*xray.ClientTraffic) (full_tr
}
}
traffics[traffic_index] = client_traffic
full_traffics = append(full_traffics, client_traffic)
}
return traffics, nil
return full_traffics, nil
}
func (s *InboundService) DisableInvalidInbounds() (int64, error) {
@@ -489,6 +489,17 @@ func (s *InboundService) DisableInvalidClients() (int64, error) {
count := result.RowsAffected
return count, err
}
func (s *InboundService) RemoveOrphanedTraffics() {
db := database.GetDB()
db.Exec(`
DELETE FROM client_traffics
WHERE email NOT IN (
SELECT JSON_EXTRACT(client.value, '$.email')
FROM inbounds,
JSON_EACH(JSON_EXTRACT(inbounds.settings, '$.clients')) AS client
)
`)
}
func (s *InboundService) AddClientStat(inboundId int, client *model.Client) error {
db := database.GetDB()

View File

@@ -69,6 +69,7 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
}
s.inboundService.DisableInvalidClients()
s.inboundService.RemoveOrphanedTraffics()
inbounds, err := s.inboundService.GetAllInbounds()
if err != nil {