3x-ui/web/job/check_inbound_job.go

36 lines
803 B
Go
Raw Normal View History

2023-02-09 22:18:06 +03:00
package job
import (
"x-ui/logger"
"x-ui/web/service"
)
type CheckInboundJob struct {
xrayService service.XrayService
inboundService service.InboundService
}
func NewCheckInboundJob() *CheckInboundJob {
return new(CheckInboundJob)
}
func (j *CheckInboundJob) Run() {
needRestart, count, err := j.inboundService.DisableInvalidClients()
2023-02-09 22:18:06 +03:00
if err != nil {
logger.Warning("Error in disabling invalid clients:", err)
2023-02-09 22:18:06 +03:00
} else if count > 0 {
logger.Debugf("%v clients disabled", count)
if needRestart {
j.xrayService.SetToNeedRestart()
}
2023-02-09 22:18:06 +03:00
}
count, err = j.inboundService.DisableInvalidInbounds()
if err != nil {
logger.Warning("Error in disabling invalid inbounds:", err)
2023-02-09 22:18:06 +03:00
} else if count > 0 {
logger.Debugf("%v inbounds disabled", count)
2023-02-09 22:18:06 +03:00
j.xrayService.SetToNeedRestart()
}
}