check_inbound_job.go 750 B

123456789101112131415161718192021222324252627282930313233
  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. count, err := j.inboundService.DisableInvalidClients()
  15. if err != nil {
  16. logger.Warning("disable invalid Client err:", err)
  17. } else if count > 0 {
  18. logger.Debugf("disabled %v Client", count)
  19. j.xrayService.SetToNeedRestart()
  20. }
  21. count, err = j.inboundService.DisableInvalidInbounds()
  22. if err != nil {
  23. logger.Warning("disable invalid inbounds err:", err)
  24. } else if count > 0 {
  25. logger.Debugf("disabled %v inbounds", count)
  26. j.xrayService.SetToNeedRestart()
  27. }
  28. }