instructions
This commit is contained in:
29
fail2ban-master/fail2ban/tests/files/action.d/action.py
Normal file
29
fail2ban-master/fail2ban/tests/files/action.d/action.py
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
from fail2ban.server.action import ActionBase
|
||||
|
||||
|
||||
class TestAction(ActionBase):
|
||||
|
||||
def __init__(self, jail, name, opt1, opt2=None):
|
||||
super(TestAction, self).__init__(jail, name)
|
||||
self._logSys.debug("%s initialised" % self.__class__.__name__)
|
||||
self.opt1 = opt1
|
||||
self.opt2 = opt2
|
||||
self._opt3 = "Hello"
|
||||
|
||||
def start(self):
|
||||
self._logSys.debug("%s action start" % self.__class__.__name__)
|
||||
|
||||
def stop(self):
|
||||
self._logSys.debug("%s action stop" % self.__class__.__name__)
|
||||
|
||||
def ban(self, aInfo):
|
||||
self._logSys.debug("%s action ban" % self.__class__.__name__)
|
||||
|
||||
def unban(self, aInfo):
|
||||
self._logSys.debug("%s action unban" % self.__class__.__name__)
|
||||
|
||||
def testmethod(self, text):
|
||||
return "%s %s %s" % (self._opt3, text, self.opt1)
|
||||
|
||||
Action = TestAction
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
from fail2ban.server.action import ActionBase
|
||||
|
||||
|
||||
class TestAction(ActionBase):
|
||||
|
||||
def ban(self, aInfo):
|
||||
self._logSys.info("ban ainfo %s, %s, %s, %s",
|
||||
aInfo["ipmatches"] != '', aInfo["ipjailmatches"] != '', aInfo["ipfailures"] > 0, aInfo["ipjailfailures"] > 0
|
||||
)
|
||||
self._logSys.info("jail info %d, %d, %d, %d",
|
||||
aInfo["jail.banned"], aInfo["jail.banned_total"], aInfo["jail.found"], aInfo["jail.found_total"]
|
||||
)
|
||||
|
||||
def unban(self, aInfo):
|
||||
pass
|
||||
|
||||
Action = TestAction
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
from fail2ban.server.action import ActionBase
|
||||
|
||||
|
||||
class TestAction(ActionBase):
|
||||
|
||||
def __init__(self, jail, name):
|
||||
super(TestAction, self).__init__(jail, name)
|
||||
|
||||
def start(self):
|
||||
raise Exception()
|
||||
|
||||
def stop(self):
|
||||
raise Exception()
|
||||
|
||||
def ban(self):
|
||||
raise Exception()
|
||||
|
||||
def unban(self):
|
||||
raise Exception()
|
||||
|
||||
Action = TestAction
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
from fail2ban.server.action import ActionBase
|
||||
|
||||
|
||||
class TestAction(ActionBase):
|
||||
|
||||
def ban(self, aInfo):
|
||||
del aInfo['ip']
|
||||
self._logSys.info("%s ban deleted aInfo IP", self._name)
|
||||
|
||||
def unban(self, aInfo):
|
||||
del aInfo['ip']
|
||||
self._logSys.info("%s unban deleted aInfo IP", self._name)
|
||||
|
||||
def flush(self):
|
||||
# intended error to cover no unhandled exception occurs in flush
|
||||
# as well as unbans are done individually after errored flush.
|
||||
raise ValueError("intended error")
|
||||
|
||||
Action = TestAction
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
from fail2ban.server.action import ActionBase
|
||||
|
||||
|
||||
class TestAction(ActionBase):
|
||||
pass
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
class TestAction():
|
||||
|
||||
def __init__(self, jail, name):
|
||||
pass
|
||||
|
||||
def start(self):
|
||||
pass
|
||||
|
||||
Action = TestAction
|
||||
Reference in New Issue
Block a user