[bug] fix parse config at starting xray

This commit is contained in:
Hossin Asaadi
2022-11-21 05:27:53 -05:00
committed by GitHub
parent 5509f945a7
commit 41cba886fd

View File

@@ -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{})
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")
// 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)
}