update pack 2

This commit is contained in:
MHSanaei
2023-02-18 16:07:32 +03:30
parent fe9844b51b
commit b412df70f1
23 changed files with 212 additions and 220 deletions

View File

@@ -6,6 +6,7 @@ import (
"sync"
"x-ui/logger"
"x-ui/xray"
"go.uber.org/atomic"
)
@@ -50,6 +51,7 @@ func (s *XrayService) GetXrayVersion() string {
}
return p.GetVersion()
}
func RemoveIndex(s []interface{}, index int) []interface{} {
return append(s[:index], s[index+1:]...)
}
@@ -79,25 +81,24 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
// get settings clients
settings := map[string]interface{}{}
json.Unmarshal([]byte(inbound.Settings), &settings)
clients, ok := 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")
if !clientTraffic.Enable {
clients = RemoveIndex(clients, index)
logger.Info("Remove Inbound User", c["email"], "due the expire or traffic limit")
}
}
}
}
settings["clients"] = clients
@@ -105,7 +106,7 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
if err != nil {
return nil, err
}
inbound.Settings = string(modifiedSettings)
}
inboundConfig := inbound.GenXrayInboundConfig()