Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Apr 11, 2023
1 parent 98d5e96 commit 4b9940f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions web/service/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 4b9940f

Please sign in to comment.