fixed shouldCleanLog

This commit is contained in:
somebodywashere 2023-06-08 19:28:04 +00:00
parent eb27951936
commit f84897e4fb

View file

@ -195,20 +195,25 @@ func updateInboundClientIps(inboundClientIps *model.InboundClientIps, clientEmai
settings := map[string][]model.Client{} settings := map[string][]model.Client{}
json.Unmarshal([]byte(inbound.Settings), &settings) json.Unmarshal([]byte(inbound.Settings), &settings)
clients := settings["clients"] clients := settings["clients"]
shouldCleanLog := false
for _, client := range clients { for _, client := range clients {
if client.Email == clientEmail { if client.Email == clientEmail {
limitIp := client.LimitIP limitIp := client.LimitIP
if limitIp < len(ips) && limitIp != 0 && inbound.Enable { if limitIp != 0 {
disAllowedIps = append(disAllowedIps, ips[limitIp:]...) shouldCleanLog = true
for i:=limitIp; i < len(ips); i++ {
logger.Info("[LIMIT_IP] Email=", clientEmail, " SRC=", ips[i]) if limitIp < len(ips) && inbound.Enable {
disAllowedIps = append(disAllowedIps, ips[limitIp:]...)
for i:=limitIp; i < len(ips); i++ {
logger.Info("[LIMIT_IP] Email=", clientEmail, " SRC=", ips[i])
}
} }
return true }
}
} }
} }
logger.Debug("disAllowedIps ", disAllowedIps) logger.Debug("disAllowedIps ", disAllowedIps)
@ -217,9 +222,9 @@ func updateInboundClientIps(inboundClientIps *model.InboundClientIps, clientEmai
db := database.GetDB() db := database.GetDB()
err = db.Save(inboundClientIps).Error err = db.Save(inboundClientIps).Error
if err != nil { if err != nil {
return false return shouldCleanLog
} }
return false return shouldCleanLog
} }
func DisableInbound(id int) error { func DisableInbound(id int) error {