jailthread.py

Go to the documentation of this file.
00001 # This file is part of Fail2Ban.
00002 #
00003 # Fail2Ban is free software; you can redistribute it and/or modify
00004 # it under the terms of the GNU General Public License as published by
00005 # the Free Software Foundation; either version 2 of the License, or
00006 # (at your option) any later version.
00007 #
00008 # Fail2Ban is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 # GNU General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU General Public License
00014 # along with Fail2Ban; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 
00017 # Author: Cyril Jaquier
00018 # 
00019 # $Revision: 567 $
00020 
00021 __author__ = "Cyril Jaquier"
00022 __version__ = "$Revision: 567 $"
00023 __date__ = "$Date: 2007-03-26 23:17:31 +0200 (Mon, 26 Mar 2007) $"
00024 __copyright__ = "Copyright (c) 2004 Cyril Jaquier"
00025 __license__ = "GPL"
00026 
00027 from threading import Thread
00028 import logging
00029 
00030 # Gets the instance of the logger.
00031 logSys = logging.getLogger("fail2ban.server")
00032 
00033 class JailThread(Thread):
00034     
00035     ##
00036     # Constructor.
00037     #
00038     # Initialize the filter object with default values.
00039     # @param jail the jail object
00040     
00041     def __init__(self):
00042         Thread.__init__(self)
00043         ## Control the state of the thread.
00044         self.__isRunning = False
00045         ## Control the idle state of the thread.
00046         self.__isIdle = False
00047         ## The time the thread sleeps in the loop.
00048         self.__sleepTime = 1
00049     
00050     ##
00051     # Set the time that the thread sleeps.
00052     #
00053     # This value could also be called "polling time". A value of 1 is a
00054     # good one. This unit is "second"
00055     # @param value the polling time (second)
00056     
00057     def setSleepTime(self, value):
00058         self.__sleepTime = value
00059         logSys.info("Set sleeptime = " + value)
00060     
00061     ##
00062     # Get the time that the thread sleeps.
00063     #
00064     # @return the polling time
00065     
00066     def getSleepTime(self):
00067         return self.__sleepTime
00068     
00069     ##
00070     # Set the idle flag.
00071     #
00072     # This flag stops the check of the log file.
00073     # @param value boolean value
00074     
00075     def setIdle(self, value):
00076         self.__isIdle = value
00077     
00078     ##
00079     # Get the idle state.
00080     #
00081     # @return the idle state
00082     
00083     def getIdle(self):
00084         return self.__isIdle
00085     
00086     ##
00087     # Stop the thread.
00088     #
00089     # Stop the exection of the thread and quit.
00090     
00091     def stop(self):
00092         self.__isRunning = False
00093     
00094     ##
00095     # Set the isRunning flag.
00096     #
00097     # @param value True if the thread is running
00098     
00099     def setActive(self, value):
00100         self.__isRunning = value
00101     
00102     ##
00103     # Check if the thread is active.
00104     #
00105     # Check if the filter thread is running.
00106     # @return True if the thread is running
00107     
00108     def _isActive(self):
00109         return self.__isRunning
00110     
00111     ##
00112     # Get the status of the thread
00113     #
00114     # Get some informations about the thread. This is an abstract method.
00115     # @return a list with tuple
00116     
00117     def status(self):
00118         pass
Generated on Tue May 21 03:01:50 2013 for Fail2Ban by  doxygen 1.6.3