check_inbound_job.go 803 B

1234567891011121314151617181920212223242526272829303132333435
  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. 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. j.xrayService.SetToNeedRestart()
  29. }
  30. }