littlefish/attackprotect.py
def service(self):
        """
        Decrease the countdowns, and remove any expired locks.  Should be called once every <decrease_every> seconds.
        """
        with self.lock:
            # Decrement / remove all attempts
            for key in list(self.attempts.keys()):
                log.debug('Decrementing count for %s' % key)
                if key in self.attempts:
                    if self.attempts[key] <= 1:
                        del self.attempts[key]
                    else:
                        self.attempts[key] -= 1

            # Remove expired locks
            now = datetime.datetime.utcnow()
            for key in list(self.locks.keys()):
                if key in self.locks and self.locks[key] < now:
                    log.info('Expiring login lock for %s' % key)
                    del self.locks[key]
def service(self):
        """
        Decrease the countdowns, and remove any expired locks.  Should be called once every <decrease_every> seconds.
        """
        with self.lock:
            # Decrement / remove all attempts
            for key in list(self.attempts.keys()):
                log.debug('Decrementing count for %s' % key)
                if key in self.attempts:
                    if self.attempts[key] <= 1:
                        del self.attempts[key]
                    else:
                        self.attempts[key] -= 1

            # Remove expired locks
            now = datetime.datetime.utcnow()
            for key in list(self.locks.keys()):
                if key in self.locks and self.locks[key] < now:
                    log.info('Expiring login lock for %s' % key)
                    del self.locks[key]
def service ( self ) : with self . lock : # Decrement / remove all attempts for key in list ( self . attempts . keys ( ) ) : log . debug ( 'Decrementing count for %s' % key ) if key in self . attempts : if self . attempts [ key ] <= 1 : del self . attempts [ key ] else : self . attempts [ key ] -= 1 # Remove expired locks now = datetime . datetime . utcnow ( ) for key in list ( self . locks . keys ( ) ) : if key in self . locks and self . locks [ key ] < now : log . info ( 'Expiring login lock for %s' % key ) del self . locks [ key ]
Decrease the countdowns, and remove any expired locks.  Should be called once every <decrease_every> seconds.
Decrease the countdowns and remove any expired locks . Should be called once every <decrease_every > seconds .