|
@@ -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
|