mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-14 05:23:09 +00:00
[bug] fix parse config at starting xray
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user