diff options
| author | Ho3ein <ho3ein.sanaei@gmail.com> | 2023-05-06 12:23:41 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-06 12:23:41 +0300 |
| commit | ac31d6d9fb666ba8deec353d0ba783eb6a8b231f (patch) | |
| tree | ea1e1764da0208035a7000f7d884a6c36b55d830 /web/service/inbound.go | |
| parent | 78638a97373bccc761f46cbbef0fda34a8dedd6c (diff) | |
| parent | 83c853ffb6b896c8a6d1eef4e0354ba1201ebf13 (diff) | |
Merge pull request #347 from hamid-gh98/main
[Feature] import/export database in the panel
Diffstat (limited to 'web/service/inbound.go')
| -rw-r--r-- | web/service/inbound.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/web/service/inbound.go b/web/service/inbound.go index dd633c4b..b14f7b4f 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -595,6 +595,7 @@ func (s *InboundService) DisableInvalidInbounds() (int64, error) { count := result.RowsAffected return count, err } + func (s *InboundService) DisableInvalidClients() (int64, error) { db := database.GetDB() now := time.Now().Unix() * 1000 @@ -605,7 +606,8 @@ func (s *InboundService) DisableInvalidClients() (int64, error) { count := result.RowsAffected return count, err } -func (s *InboundService) RemoveOrphanedTraffics() { + +func (s *InboundService) MigrationRemoveOrphanedTraffics() { db := database.GetDB() db.Exec(` DELETE FROM client_traffics @@ -616,6 +618,7 @@ func (s *InboundService) RemoveOrphanedTraffics() { ) `) } + func (s *InboundService) AddClientStat(inboundId int, client *model.Client) error { db := database.GetDB() @@ -634,6 +637,7 @@ func (s *InboundService) AddClientStat(inboundId int, client *model.Client) erro } return nil } + func (s *InboundService) UpdateClientStat(email string, client *model.Client) error { db := database.GetDB() @@ -1166,3 +1170,8 @@ func (s *InboundService) MigrationRequirements() { // Remove orphaned traffics db.Where("inbound_id = 0").Delete(xray.ClientTraffic{}) } + +func (s *InboundService) MigrateDB() { + s.MigrationRequirements() + s.MigrationRemoveOrphanedTraffics() +} |
