mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-21 23:41:01 +00:00
Tweak ban logic, update config description
This commit is contained in:
parent
3a7527c418
commit
66f62efcbb
2 changed files with 4 additions and 3 deletions
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue