Skip to content

Commit

Permalink
[bug] fix restarting core on disabling depleted user
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Oct 10, 2024
1 parent fdd3df7 commit 56c5b0d
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions web/service/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,12 @@ func (s *InboundService) DelInboundClient(inboundId int, clientId string) (bool,
logger.Debug("Client deleted by api:", email)
needRestart = false
} else {
logger.Debug("Unable to del client by api:", err1)
needRestart = true
if strings.Contains(err1.Error(), fmt.Sprintf("User %s not found.", email)) {
logger.Debug("User is already disabled. Nothing to do more...")
} else {
logger.Debug("Error in disabling client by api:", err1)
needRestart = true
}
}
s.xrayApi.Close()
}
Expand Down Expand Up @@ -681,10 +685,14 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin
if oldClients[clientIndex].Enable {
err1 := s.xrayApi.RemoveUser(oldInbound.Tag, oldEmail)
if err1 == nil {
logger.Debug("Old client deleted by api:", clients[0].Email)
logger.Debug("Old client deleted by api:", oldEmail)
} else {
logger.Debug("Error in deleting client by api:", err1)
needRestart = true
if strings.Contains(err1.Error(), fmt.Sprintf("User %s not found.", oldEmail)) {
logger.Debug("User is already disabled. Nothing to do more...")
} else {
logger.Debug("Error in disabling client by api:", err1)
needRestart = true
}
}
}
if clients[0].Enable {
Expand Down Expand Up @@ -1043,8 +1051,12 @@ func (s *InboundService) disableInvalidClients(tx *gorm.DB) (bool, int64, error)
if err1 == nil {
logger.Debug("Client disabled by api:", result.Email)
} else {
logger.Debug("Error in disabling client by api:", err1)
needRestart = true
if strings.Contains(err1.Error(), fmt.Sprintf("User %s not found.", result.Email)) {
logger.Debug("User is already disabled. Nothing to do more...")
} else {
logger.Debug("Error in disabling client by api:", err1)
needRestart = true
}
}
}
s.xrayApi.Close()
Expand Down

0 comments on commit 56c5b0d

Please sign in to comment.