1
0

check_inbound_job.go 840 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package job
  2. import (
  3. "x-ui/logger"
  4. "x-ui/web/service"
  5. )
  6. type CheckInboundJob struct {
  7. xrayService service.XrayService
  8. inboundService service.InboundService
  9. }
  10. func NewCheckInboundJob() *CheckInboundJob {
  11. return new(CheckInboundJob)
  12. }
  13. func (j *CheckInboundJob) Run() {
  14. needRestart, count, err := j.inboundService.DisableInvalidClients()
  15. if err != nil {
  16. logger.Warning("Error in disabling invalid clients:", err)
  17. } else if count > 0 {
  18. logger.Debugf("%v clients disabled", count)
  19. if needRestart {
  20. j.xrayService.SetToNeedRestart()
  21. }
  22. }
  23. needRestart, count, err = j.inboundService.DisableInvalidInbounds()
  24. if err != nil {
  25. logger.Warning("Error in disabling invalid inbounds:", err)
  26. } else if count > 0 {
  27. logger.Debugf("%v inbounds disabled", count)
  28. if needRestart {
  29. j.xrayService.SetToNeedRestart()
  30. }
  31. }
  32. }