Skip to content
Snippets Groups Projects
Commit 66f62efc authored by Piero Toffanin's avatar Piero Toffanin
Browse files

Tweak ban logic, update config description

parent 3a7527c4
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ threshold = -1
def forgive_banned():
global banned
global threshold
clear_list = []
......@@ -16,7 +17,7 @@ def forgive_banned():
if banned[ip] <= 0:
clear_list.append(ip)
else:
banned[ip] -= 1
banned[ip] = min(threshold, banned[ip]) - 1
for ip in clear_list:
del banned[ip]
......@@ -29,7 +30,7 @@ def setup(violations_threshold=100):
threshold = violations_threshold
scheduler = BackgroundScheduler()
scheduler.add_job(func=forgive_banned, trigger="interval", minutes=5)
scheduler.add_job(func=forgive_banned, trigger="interval", minutes=60)
scheduler.start()
# Shut down the scheduler when exiting the app
......
......@@ -40,7 +40,7 @@ def main():
default=DEFARGS['REQ_FLOOD_THRESHOLD'],
type=int,
metavar="<number>",
help="Set the maximum number of request limit offences per 4 weeks that a client can exceed before being banned. (%(default)s)",
help="Set the maximum number of request limit offences that a client can exceed before being banned. (%(default)s)",
)
parser.add_argument(
"--batch-limit",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment