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