mirror of https://github.com/fail2ban/fail2ban
- Replaced loop with list comprehension
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@454 a942ae1a-1317-0410-a47c-b1dcaea8d6050.x
parent
32b33c8ae4
commit
f8989581b4
|
@ -136,14 +136,6 @@ class BanManager:
|
||||||
finally:
|
finally:
|
||||||
self.__lock.release()
|
self.__lock.release()
|
||||||
|
|
||||||
##
|
|
||||||
# Delete a ban ticket.
|
|
||||||
#
|
|
||||||
# Remove a BanTicket from the ban list.
|
|
||||||
# @param ticket the ticket
|
|
||||||
|
|
||||||
def __delBanTicket(self, ticket):
|
|
||||||
self.__banList.remove(ticket)
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Get the size of the ban list.
|
# Get the size of the ban list.
|
||||||
|
@ -177,20 +169,23 @@ class BanManager:
|
||||||
# Return a list of BanTicket which need to be unbanned.
|
# Return a list of BanTicket which need to be unbanned.
|
||||||
# @param time the time
|
# @param time the time
|
||||||
# @return the list of ticket to unban
|
# @return the list of ticket to unban
|
||||||
# @todo Check the delete operation
|
|
||||||
|
|
||||||
def unBanList(self, time):
|
def unBanList(self, time):
|
||||||
try:
|
try:
|
||||||
self.__lock.acquire()
|
self.__lock.acquire()
|
||||||
uBList = list()
|
|
||||||
# Permanent banning
|
# Permanent banning
|
||||||
if self.__banTime < 0:
|
if self.__banTime < 0:
|
||||||
return uBList
|
return list()
|
||||||
for ticket in self.__banList:
|
|
||||||
if ticket.getTime() < time - self.__banTime:
|
# Gets the list of ticket to remove.
|
||||||
uBList.append(ticket)
|
unBanList = [ticket for ticket in self.__banList
|
||||||
self.__delBanTicket(ticket)
|
if ticket.getTime() < time - self.__banTime]
|
||||||
return uBList
|
|
||||||
|
# Removes tickets.
|
||||||
|
self.__banList = [ticket for ticket in self.__banList
|
||||||
|
if ticket not in unBanList]
|
||||||
|
|
||||||
|
return unBanList
|
||||||
finally:
|
finally:
|
||||||
self.__lock.release()
|
self.__lock.release()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue