Przeglądaj źródła

bug fix

Co-Authored-By: Alireza Ahmadi <[email protected]>
MHSanaei 1 rok temu
rodzic
commit
8c40e7281f
1 zmienionych plików z 13 dodań i 6 usunięć
  1. 13 6
      web/service/inbound.go

+ 13 - 6
web/service/inbound.go

@@ -453,12 +453,10 @@ func (s *InboundService) adjustTraffics(traffics []*xray.ClientTraffic) (full_tr
 			}
 			continue
 		}
-		// get settings clients
-		settings := map[string]interface{}{}
-		json.Unmarshal([]byte(inbound.Settings), &settings)
-		clients, ok := settings["clients"].([]model.Client)
+		// get clients
+		clients, err := s.getClients(inbound)
 		needUpdate := false
-		if ok {
+		if err == nil {
 			for client_index, client := range clients {
 				if traffic.Email == client.Email {
 					if client.ExpiryTime < 0 {
@@ -473,7 +471,16 @@ func (s *InboundService) adjustTraffics(traffics []*xray.ClientTraffic) (full_tr
 		}
 
 		if needUpdate {
-			settings["clients"] = clients
+			settings := map[string]interface{}{}
+			json.Unmarshal([]byte(inbound.Settings), &settings)
+
+			// Convert clients to []interface to update clients in settings
+			var clientsInterface []interface{}
+			for _, c := range clients {
+				clientsInterface = append(clientsInterface, interface{}(c))
+			}
+
+			settings["clients"] = clientsInterface
 			modifiedSettings, err := json.MarshalIndent(settings, "", "  ")
 			if err != nil {
 				return nil, err