[bug] fix restarting core on disabling depleted user

This commit is contained in:
Alireza Ahmadi 2024-10-10 17:37:06 +02:00
parent 4b1c76e972
commit 1454c4ebc5

View file

@ -1037,10 +1037,14 @@ func (s *InboundService) disableInvalidInbounds(tx *gorm.DB) (bool, int64, error
if err1 == nil { if err1 == nil {
logger.Debug("Inbound disabled by api:", tag) logger.Debug("Inbound disabled by api:", tag)
} else { } else {
logger.Debug("Error in disabling inbound by api:", err1) if strings.Contains(err1.Error(), fmt.Sprintf("User %s not found.", tag)) {
logger.Debug("User is already disabled. Nothing to do more...")
} else {
logger.Debug("Error in disabling client by api:", err1)
needRestart = true needRestart = true
} }
} }
}
s.xrayApi.Close() s.xrayApi.Close()
} }
@ -1075,11 +1079,19 @@ func (s *InboundService) disableInvalidClients(tx *gorm.DB) (bool, int64, error)
err1 := s.xrayApi.RemoveUser(result.Tag, result.Email) err1 := s.xrayApi.RemoveUser(result.Tag, result.Email)
if err1 == nil { if err1 == nil {
logger.Debug("Client disabled by api:", result.Email) logger.Debug("Client disabled by api:", result.Email)
} else {
if strings.Contains(err1.Error(), fmt.Sprintf("User %s not found.", result.Email)) {
logger.Debug("User is already disabled. Nothing to do more...")
} else {
if strings.Contains(err1.Error(), fmt.Sprintf("User %s not found.", result.Email)) {
logger.Debug("User is already disabled. Nothing to do more...")
} else { } else {
logger.Debug("Error in disabling client by api:", err1) logger.Debug("Error in disabling client by api:", err1)
needRestart = true needRestart = true
} }
} }
}
}
s.xrayApi.Close() s.xrayApi.Close()
} }
result := tx.Model(xray.ClientTraffic{}). result := tx.Model(xray.ClientTraffic{}).