Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/web/job
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-08-26 14:49:51 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-08-26 14:49:51 +0300
commit1277285d0835fdf2f2184f067140e2390fa083bb (patch)
tree3cead6275d1fe3985b28441dab42e08432f571c0 /web/job
parent75df8a05f1fa0bcc914f1b132f8c99c5497367c3 (diff)
[db] Enbancement add traffic fully transactional
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/job')
-rw-r--r--web/job/check_inbound_job.go37
-rw-r--r--web/job/xray_traffic_job.go8
2 files changed, 3 insertions, 42 deletions
diff --git a/web/job/check_inbound_job.go b/web/job/check_inbound_job.go
deleted file mode 100644
index 2044ce68..00000000
--- a/web/job/check_inbound_job.go
+++ /dev/null
@@ -1,37 +0,0 @@
-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()
- if err != nil {
- logger.Warning("Error in disabling invalid clients:", err)
- } else if count > 0 {
- logger.Debugf("%v clients disabled", count)
- if needRestart {
- j.xrayService.SetToNeedRestart()
- }
- }
-
- needRestart, count, err = j.inboundService.DisableInvalidInbounds()
- if err != nil {
- logger.Warning("Error in disabling invalid inbounds:", err)
- } else if count > 0 {
- logger.Debugf("%v inbounds disabled", count)
- if needRestart {
- j.xrayService.SetToNeedRestart()
- }
- }
-}
diff --git a/web/job/xray_traffic_job.go b/web/job/xray_traffic_job.go
index 3acdf44a..158930a4 100644
--- a/web/job/xray_traffic_job.go
+++ b/web/job/xray_traffic_job.go
@@ -24,14 +24,12 @@ func (j *XrayTrafficJob) Run() {
logger.Warning("get xray traffic failed:", err)
return
}
- err = j.inboundService.AddTraffic(traffics)
+ err, needRestart := j.inboundService.AddTraffic(traffics, clientTraffics)
if err != nil {
logger.Warning("add traffic failed:", err)
}
-
- err = j.inboundService.AddClientTraffic(clientTraffics)
- if err != nil {
- logger.Warning("add client traffic failed:", err)
+ if needRestart {
+ j.xrayService.SetToNeedRestart()
}
}