Files
trihuy-russian/web/job/check_inbound_job.go
T

38 lines
840 B
Go
Raw Normal View History

2023-02-09 22:48:06 +03:30
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() {
2023-06-05 00:32:19 +03:30
needRestart, count, err := j.inboundService.DisableInvalidClients()
2023-02-09 22:48:06 +03:30
if err != nil {
2023-06-05 00:32:19 +03:30
logger.Warning("Error in disabling invalid clients:", err)
2023-02-09 22:48:06 +03:30
} else if count > 0 {
2023-06-05 00:32:19 +03:30
logger.Debugf("%v clients disabled", count)
if needRestart {
j.xrayService.SetToNeedRestart()
}
2023-02-09 22:48:06 +03:30
}
2023-07-18 02:40:22 +03:30
needRestart, count, err = j.inboundService.DisableInvalidInbounds()
2023-02-09 22:48:06 +03:30
if err != nil {
2023-06-05 00:32:19 +03:30
logger.Warning("Error in disabling invalid inbounds:", err)
2023-02-09 22:48:06 +03:30
} else if count > 0 {
2023-06-05 00:32:19 +03:30
logger.Debugf("%v inbounds disabled", count)
2023-07-18 02:40:22 +03:30
if needRestart {
j.xrayService.SetToNeedRestart()
}
2023-02-09 22:48:06 +03:30
}
}