From 6b23b416a788aedeacd75e445f8b1a919c2cf5c8 Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Sun, 17 Aug 2025 13:37:49 +0200 Subject: minor changes --- web/job/check_client_ip_job.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'web/job') 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{} -- cgit v1.2.3