diff options
Diffstat (limited to 'web/job')
| -rw-r--r-- | web/job/check_client_ip_job.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/web/job/check_client_ip_job.go b/web/job/check_client_ip_job.go index b95c8ee2..5a30b616 100644 --- a/web/job/check_client_ip_job.go +++ b/web/job/check_client_ip_job.go @@ -11,7 +11,6 @@ import ( "sort" "time" - "slices" "x-ui/database" "x-ui/database/model" "x-ui/logger" @@ -58,21 +57,21 @@ func (j *CheckClientIpJob) Run() { func (j *CheckClientIpJob) clearAccessLog() { logAccessP, err := os.OpenFile(xray.GetAccessPersistentLogPath(), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o644) j.checkError(err) + defer logAccessP.Close() accessLogPath, err := xray.GetAccessLogPath() j.checkError(err) file, err := os.Open(accessLogPath) j.checkError(err) + defer file.Close() _, err = io.Copy(logAccessP, file) j.checkError(err) - logAccessP.Close() - file.Close() - err = os.Truncate(accessLogPath, 0) j.checkError(err) + j.lastClear = time.Now().Unix() } @@ -193,10 +192,6 @@ func (j *CheckClientIpJob) checkError(e error) { } } -func (j *CheckClientIpJob) contains(s []string, str string) bool { - return slices.Contains(s, str) -} - func (j *CheckClientIpJob) getInboundClientIps(clientEmail string) (*model.InboundClientIps, error) { db := database.GetDB() InboundClientIps := &model.InboundClientIps{} |
