|
|
@ -85,6 +85,8 @@ class Filter(JailThread):
|
|
|
|
self.__lastDate = None
|
|
|
|
self.__lastDate = None
|
|
|
|
## External command
|
|
|
|
## External command
|
|
|
|
self.__ignoreCommand = False
|
|
|
|
self.__ignoreCommand = False
|
|
|
|
|
|
|
|
## Error counter
|
|
|
|
|
|
|
|
self.__errors = 0
|
|
|
|
|
|
|
|
|
|
|
|
self.dateDetector = DateDetector()
|
|
|
|
self.dateDetector = DateDetector()
|
|
|
|
self.dateDetector.addDefaultTemplate()
|
|
|
|
self.dateDetector.addDefaultTemplate()
|
|
|
@ -414,26 +416,39 @@ class Filter(JailThread):
|
|
|
|
def processLineAndAdd(self, line, date=None):
|
|
|
|
def processLineAndAdd(self, line, date=None):
|
|
|
|
"""Processes the line for failures and populates failManager
|
|
|
|
"""Processes the line for failures and populates failManager
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
for element in self.processLine(line, date)[1]:
|
|
|
|
try:
|
|
|
|
ip = element[1]
|
|
|
|
for element in self.processLine(line, date)[1]:
|
|
|
|
unixTime = element[2]
|
|
|
|
ip = element[1]
|
|
|
|
lines = element[3]
|
|
|
|
unixTime = element[2]
|
|
|
|
fail = {}
|
|
|
|
lines = element[3]
|
|
|
|
if len(element) > 4:
|
|
|
|
fail = {}
|
|
|
|
fail = element[4]
|
|
|
|
if len(element) > 4:
|
|
|
|
logSys.debug("Processing line with time:%s and ip:%s",
|
|
|
|
fail = element[4]
|
|
|
|
unixTime, ip)
|
|
|
|
logSys.debug("Processing line with time:%s and ip:%s",
|
|
|
|
if unixTime < MyTime.time() - self.getFindTime():
|
|
|
|
unixTime, ip)
|
|
|
|
logSys.debug("Ignore line since time %s < %s - %s",
|
|
|
|
if unixTime < MyTime.time() - self.getFindTime():
|
|
|
|
unixTime, MyTime.time(), self.getFindTime())
|
|
|
|
logSys.debug("Ignore line since time %s < %s - %s",
|
|
|
|
break
|
|
|
|
unixTime, MyTime.time(), self.getFindTime())
|
|
|
|
if self.inIgnoreIPList(ip, log_ignore=True):
|
|
|
|
break
|
|
|
|
continue
|
|
|
|
if self.inIgnoreIPList(ip, log_ignore=True):
|
|
|
|
logSys.info(
|
|
|
|
continue
|
|
|
|
"[%s] Found %s - %s", self.jail.name, ip, datetime.datetime.fromtimestamp(unixTime).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
logSys.info(
|
|
|
|
)
|
|
|
|
"[%s] Found %s - %s", self.jail.name, ip, datetime.datetime.fromtimestamp(unixTime).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
tick = FailTicket(ip, unixTime, lines, data=fail)
|
|
|
|
)
|
|
|
|
self.failManager.addFailure(tick)
|
|
|
|
tick = FailTicket(ip, unixTime, lines, data=fail)
|
|
|
|
|
|
|
|
self.failManager.addFailure(tick)
|
|
|
|
|
|
|
|
# reset (halve) error counter (successfully processed line):
|
|
|
|
|
|
|
|
if self.__errors:
|
|
|
|
|
|
|
|
self.__errors //= 2
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
logSys.error("Failed to process line: %r, caught exception: %r", line, e,
|
|
|
|
|
|
|
|
exc_info=logSys.getEffectiveLevel()<=logging.DEBUG)
|
|
|
|
|
|
|
|
# incr error counter, stop processing this :
|
|
|
|
|
|
|
|
self.__errors += 1
|
|
|
|
|
|
|
|
if self.__errors >= 100:
|
|
|
|
|
|
|
|
logSys.error("Too many errors at once (%s), going idle", self.__errors)
|
|
|
|
|
|
|
|
self.__errors //= 2
|
|
|
|
|
|
|
|
self.idle = True
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
##
|
|
|
|
# Returns true if the line should be ignored.
|
|
|
|
# Returns true if the line should be ignored.
|
|
|
|