mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-05 07:20:13 +01:00
Tweak ban logic, update config description
This commit is contained in:
parent
3a7527c418
commit
66f62efcbb
@ -9,6 +9,7 @@ threshold = -1
|
|||||||
|
|
||||||
def forgive_banned():
|
def forgive_banned():
|
||||||
global banned
|
global banned
|
||||||
|
global threshold
|
||||||
|
|
||||||
clear_list = []
|
clear_list = []
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ def forgive_banned():
|
|||||||
if banned[ip] <= 0:
|
if banned[ip] <= 0:
|
||||||
clear_list.append(ip)
|
clear_list.append(ip)
|
||||||
else:
|
else:
|
||||||
banned[ip] -= 1
|
banned[ip] = min(threshold, banned[ip]) - 1
|
||||||
|
|
||||||
for ip in clear_list:
|
for ip in clear_list:
|
||||||
del banned[ip]
|
del banned[ip]
|
||||||
@ -29,7 +30,7 @@ def setup(violations_threshold=100):
|
|||||||
threshold = violations_threshold
|
threshold = violations_threshold
|
||||||
|
|
||||||
scheduler = BackgroundScheduler()
|
scheduler = BackgroundScheduler()
|
||||||
scheduler.add_job(func=forgive_banned, trigger="interval", minutes=5)
|
scheduler.add_job(func=forgive_banned, trigger="interval", minutes=60)
|
||||||
scheduler.start()
|
scheduler.start()
|
||||||
|
|
||||||
# Shut down the scheduler when exiting the app
|
# Shut down the scheduler when exiting the app
|
||||||
|
@ -40,7 +40,7 @@ def main():
|
|||||||
default=DEFARGS['REQ_FLOOD_THRESHOLD'],
|
default=DEFARGS['REQ_FLOOD_THRESHOLD'],
|
||||||
type=int,
|
type=int,
|
||||||
metavar="<number>",
|
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(
|
parser.add_argument(
|
||||||
"--batch-limit",
|
"--batch-limit",
|
||||||
|
Loading…
Reference in New Issue
Block a user