Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
[bug] fix parse config at starting xray
Browse files Browse the repository at this point in the history
  • Loading branch information
hossinasaadi committed Nov 21, 2022
1 parent 5509f94 commit 41cba88
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions web/service/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,35 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
// get settings clients
settings := map[string]interface{}{}
json.Unmarshal([]byte(inbound.Settings), &settings)
clients := settings["clients"].([]interface{})



// check users active or not

clientStats := inbound.ClientStats
for _, clientTraffic := range clientStats {

for index, client := range clients {
c := client.(map[string]interface{})
if c["email"] == clientTraffic.Email {
if ! clientTraffic.Enable {
clients = RemoveIndex(clients,index)
logger.Info("Remove Inbound User",c["email"] ,"due the expire or traffic limit")
clients, ok := settings["clients"].([]interface{})
if ok {
// check users active or not

clientStats := inbound.ClientStats
for _, clientTraffic := range clientStats {
for index, client := range clients {
c := client.(map[string]interface{})
if c["email"] == clientTraffic.Email {
if ! clientTraffic.Enable {
clients = RemoveIndex(clients,index)
logger.Info("Remove Inbound User",c["email"] ,"due the expire or traffic limit")

}

}

}
}



}
settings["clients"] = clients
modifiedSettings, err := json.Marshal(settings)
if err != nil {
return nil, err
}

inbound.Settings = string(modifiedSettings)
}
settings["clients"] = clients
modifiedSettings, err := json.Marshal(settings)
if err != nil {
return nil, err
}

inbound.Settings = string(modifiedSettings)

inboundConfig := inbound.GenXrayInboundConfig()
xrayConfig.InboundConfigs = append(xrayConfig.InboundConfigs, *inboundConfig)
}
Expand Down

0 comments on commit 41cba88

Please sign in to comment.