This commit is contained in:
Alireza Ahmadi
2023-04-11 14:25:06 +02:00
parent 98d5e960a4
commit 4b9940fb06

View File

@@ -425,12 +425,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 {
@@ -445,7 +443,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