diff options
author | Christian Hesse <mail@eworm.de> | 2020-09-28 20:20:19 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-09-28 20:20:19 +0200 |
commit | 744542e92539eb6ad39c84eca05258f82e1dd47a (patch) | |
tree | 6adcf493d2115f362ff1602de1570f859a08828a /log-forward | |
parent | 42289b6239a6d4f622b91ca81048c25d0832722f (diff) |
log-forward: add rate limit to prevent flooding
Diffstat (limited to 'log-forward')
-rw-r--r-- | log-forward | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/log-forward b/log-forward index 7da8a4a..27aa19c 100644 --- a/log-forward +++ b/log-forward @@ -10,6 +10,7 @@ :global LogForwardFilter; :global LogForwardFilterMessage; :global LogForwardLast; +:global LogForwardRateLimit; :global LogPrintExit; :global MailServerIsUp; @@ -20,6 +21,15 @@ $ScriptLock "log-forward"; +:if ([ :typeof $LogForwardRateLimit ] = "nothing") do={ + :set LogForwardRateLimit 0; +} + +:if ($LogForwardRateLimit > 30) do={ + :set LogForwardRateLimit ($LogForwardRateLimit - 1); + $LogPrintExit info ("Rate limit in action, not forwarding logs!") true; +} + $WaitFullyConnected; :if ([ $MailServerIsUp ] = false) do={ @@ -48,5 +58,10 @@ $WaitFullyConnected; ("The log on " . $Identity . " contains these " . $Count . " messages after " . \ [ / system resource get uptime ] . " uptime.\n" . $Messages); + :set LogForwardRateLimit ($LogForwardRateLimit + 10); :set LogForwardLast ($MessageVal->".id"); +} else={ + :if ($LogForwardRateLimit > 0) do={ + :set LogForwardRateLimit ($LogForwardRateLimit - 1); + } } |