mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 20:51:49 +02:00
Reset attempt counters if they get memory hungry
This commit is contained in:
parent
d8307f4672
commit
b8685c0af2
1 changed files with 3 additions and 0 deletions
|
@ -149,6 +149,9 @@ class LoginThrottler():
|
||||||
return self._max_attempts - self._attempts.get(ip, [datetime.now(), 0])[1]
|
return self._max_attempts - self._attempts.get(ip, [datetime.now(), 0])[1]
|
||||||
|
|
||||||
def increment_attempts_counter(self, ip):
|
def increment_attempts_counter(self, ip):
|
||||||
|
# Reset all attempt counters when they get hungry for memory
|
||||||
|
if len(self._attempts) > 10000:
|
||||||
|
self.__init__()
|
||||||
if self._attempts.get(ip) is None:
|
if self._attempts.get(ip) is None:
|
||||||
# Store first attempt date and number of attempts since
|
# Store first attempt date and number of attempts since
|
||||||
self._attempts[ip] = [datetime.now(), 0]
|
self._attempts[ip] = [datetime.now(), 0]
|
||||||
|
|
Loading…
Reference in a new issue