From 289a33675f08cd329d7b0defc087e3d01ba4df08 Mon Sep 17 00:00:00 2001 From: somebodywashere <68244480+somebodywashere@users.noreply.github.com> Date: Wed, 14 Jun 2023 09:26:21 +0000 Subject: [PATCH] added 5 seconds delay before cleaning logs --- web/job/check_client_ip_job.go | 5 ++++- web/web.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/web/job/check_client_ip_job.go b/web/job/check_client_ip_job.go index 9e988ce2..87789517 100644 --- a/web/job/check_client_ip_job.go +++ b/web/job/check_client_ip_job.go @@ -12,6 +12,7 @@ import ( "sort" "strings" + "time" ) type CheckClientIpJob struct { @@ -97,7 +98,9 @@ func processLogFile() { } } - + + time.Sleep(time.Second * 5) + //added 5 seconds delay before cleaning logs to reduce chance of logging IP that already has been banned if shouldCleanLog { // clean log if err := os.Truncate(GetAccessLogPath(), 0); err != nil { diff --git a/web/web.go b/web/web.go index cea0e911..a70ae3c8 100644 --- a/web/web.go +++ b/web/web.go @@ -250,7 +250,7 @@ func (s *Server) startTask() { // Check the inbound traffic every 30 seconds that the traffic exceeds and expires s.cron.AddJob("@every 30s", job.NewCheckInboundJob()) - // check client ips from log file every 10 sec + // check client ips from log file every 30 sec s.cron.AddJob("@every 30s", job.NewCheckClientIpJob()) // Make a traffic condition every day, 8:30