From b9e3d362352e9eed05d7ba0b97c383d69d01f21e Mon Sep 17 00:00:00 2001 From: somebodywashere <68244480+somebodywashere@users.noreply.github.com> Date: Fri, 23 Jun 2023 18:31:27 +0000 Subject: [PATCH] Updated copying of access.log --- web/job/check_client_ip_job.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/job/check_client_ip_job.go b/web/job/check_client_ip_job.go index 51bf5d7e..758929e9 100644 --- a/web/job/check_client_ip_job.go +++ b/web/job/check_client_ip_job.go @@ -146,11 +146,14 @@ func processLogFile() { //added 3 seconds delay before cleaning logs to reduce chance of logging IP that already has been banned if shouldCleanLog { //copy log + logAccessP, err := os.OpenFile("/usr/local/x-ui/accessp.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644) + checkError(err) input, err := os.ReadFile(accessLogPath) checkError(err) - if err := os.WriteFile("/usr/local/x-ui/accessp.log", input, 0644); err != nil { + if _, err := logAccessP.Write(input); err != nil { checkError(err) } + defer logAccessP.Close() // clean log if err := os.Truncate(GetAccessLogPath(), 0); err != nil { checkError(err)