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

Improve banned forgiveness logic

parent cda2d3ed
No related branches found
No related tags found
No related merge requests found
......@@ -7,10 +7,19 @@ active = False
threshold = -1
def clear_banned():
def forgive_banned():
global banned
banned = {}
clear_list = []
for ip in banned:
if banned[ip] <= 0:
clear_list.append(ip)
else:
banned[ip] -= 1
for ip in clear_list:
del banned[ip]
def setup(violations_threshold=100):
global active
......@@ -20,7 +29,7 @@ def setup(violations_threshold=100):
threshold = violations_threshold
scheduler = BackgroundScheduler()
scheduler.add_job(func=clear_banned, trigger="interval", weeks=4)
scheduler.add_job(func=forgive_banned, trigger="interval", minutes=5)
scheduler.start()
# Shut down the scheduler when exiting the app
......
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