~ubuntu-branches/ubuntu/saucy/fail2ban/saucy

« back to all changes in this revision

Viewing changes to server/banmanager.py

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-05-13 11:58:56 UTC
  • mfrom: (1.1.15) (10.2.13 sid)
  • Revision ID: package-import@ubuntu.com-20130513115856-x7six9p53qcie0vl
Tags: 0.8.9-1
* New upstream release
  - significant improvements in documentation (Closes: #400416)
  - roundcube auth filter (Closes: #699442)
  - enforces C locale for dates (Closes: #686341)
  - provides bash_completion.d/fail2ban
* debian/jail.conf:
  - added findtime and documentation on those basic options from jail.conf
    (Closes: #704568)
  - added new sample jails definitions for ssh-route, ssh-iptables-ipset{4,6},
    roundcube-auth, sogo-auth, mysqld-auth
* debian/control:
  - suggest system-log-daemon (Closes: #691001)
  - boost policy compliance to 3.9.4
* debian/rules:
  - run fail2ban's unittests at build time but ignore the failures
    (there are still some known issues to fix up to guarantee robust testing
    in clean chroots etc).
    Only pyinotify was added to build-depends since gamin might still be
    buggy on older releases and get stuck, which would complicate
    backporting

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
# Author: Cyril Jaquier
21
21
22
 
# $Revision$
23
22
 
24
23
__author__ = "Cyril Jaquier"
25
 
__version__ = "$Revision$"
26
 
__date__ = "$Date$"
27
24
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
28
25
__license__ = "GPL"
29
26
 
148
145
        def addBanTicket(self, ticket):
149
146
                try:
150
147
                        self.__lock.acquire()
151
 
                        if not self.__inBanList(ticket):
 
148
                        if not self._inBanList(ticket):
152
149
                                self.__banList.append(ticket)
153
150
                                self.__banTotal += 1
154
151
                                return True
177
174
        # @param ticket the ticket
178
175
        # @return True if a ticket already exists
179
176
        
180
 
        def __inBanList(self, ticket):
 
177
        def _inBanList(self, ticket):
181
178
                for i in self.__banList:
182
179
                        if ticket.getIP() == i.getIP():
183
180
                                return True
208
205
                        return unBanList
209
206
                finally:
210
207
                        self.__lock.release()
211
 
        
 
208
 
212
209
        ##
213
210
        # Flush the ban list.
214
211
        #
223
220
                        return uBList
224
221
                finally:
225
222
                        self.__lock.release()
 
223
 
 
224
        ##
 
225
        # Gets the ticket for the specified IP.
 
226
        #
 
227
        # @return the ticket for the IP or False.
 
228
        def getTicketByIP(self, ip):
 
229
                try:
 
230
                        self.__lock.acquire()
 
231
 
 
232
                        # Find the ticket the IP goes with and return it
 
233
                        for i, ticket in enumerate(self.__banList):
 
234
                                if ticket.getIP() == ip:
 
235
                                        # Return the ticket after removing (popping)
 
236
                                        # if from the ban list.
 
237
                                        return self.__banList.pop(i)
 
238
                finally:
 
239
                        self.__lock.release()
 
240
                return None                                               # if none found