Browse Source

[migration] add fix for omitted traffics

Co-Authored-By: Alireza Ahmadi <[email protected]>
MHSanaei 1 year ago
parent
commit
bc06dbab21
2 changed files with 15 additions and 1 deletions
  1. 2 1
      web/controller/util.go
  2. 13 0
      web/service/inbound.go

+ 2 - 1
web/controller/util.go

@@ -1,13 +1,14 @@
 package controller
 
 import (
-	"github.com/gin-gonic/gin"
 	"net"
 	"net/http"
 	"strings"
 	"x-ui/config"
 	"x-ui/logger"
 	"x-ui/web/entity"
+
+	"github.com/gin-gonic/gin"
 )
 
 func getUriId(c *gin.Context) int64 {

+ 13 - 0
web/service/inbound.go

@@ -868,6 +868,19 @@ func (s *InboundService) MigrationRequirements() {
 
 			inbounds[inbound_index].Settings = string(modifiedSettings)
 		}
+		modelClients, err := s.getClients(inbounds[inbound_index])
+		if err != nil {
+			return
+		}
+		for _, modelClient := range modelClients {
+			if len(modelClient.Email) > 0 {
+				var count int64
+				db.Model(xray.ClientTraffic{}).Where("email = ?", modelClient.Email).Count(&count)
+				if count == 0 {
+					s.AddClientStat(inbounds[inbound_index].Id, &modelClient)
+				}
+			}
+		}
 	}
 	db.Save(inbounds)
 }