mirror of https://github.com/fail2ban/fail2ban
DOC: Add documentation for badips.py action
parent
dfb46cfda6
commit
0c63d0061a
|
@ -62,6 +62,8 @@ configuration before relying on it.
|
|||
Close gh-347
|
||||
* Filter for squirrelmail. Close gh-261
|
||||
* Filter for tine20. Close gh-583
|
||||
* Added action to use badips.com reporting and blacklist
|
||||
- Requires Python 2.7+
|
||||
|
||||
- Enhancements
|
||||
* Jail names increased to 26 characters and iptables prefix reduced
|
||||
|
|
|
@ -39,14 +39,6 @@ class BadIPsAction(ActionBase):
|
|||
"""Fail2Ban action which resports bans to badips.com, and also
|
||||
blacklist bad IPs listed on badips.com by using another action's
|
||||
ban method.
|
||||
"""
|
||||
badips = "http://www.badips.com"
|
||||
Request = partial(
|
||||
Request, headers={'User-Agent': "Fail2Ban %s" % f2bVersion})
|
||||
|
||||
def __init__(self, jail, name, category, score=5, age="24h",
|
||||
banaction=None, bancategory=None, updateperiod=900):
|
||||
"""Initialise action.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
@ -79,6 +71,13 @@ class BadIPsAction(ActionBase):
|
|||
ValueError
|
||||
If invalid `category`, `score`, `banaction` or `updateperiod`.
|
||||
"""
|
||||
|
||||
_badips = "http://www.badips.com"
|
||||
_Request = partial(
|
||||
Request, headers={'User-Agent': "Fail2Ban %s" % f2bVersion})
|
||||
|
||||
def __init__(self, jail, name, category, score=5, age="24h",
|
||||
banaction=None, bancategory=None, updateperiod=900):
|
||||
super(BadIPsAction, self).__init__(jail, name)
|
||||
|
||||
self.category = category
|
||||
|
@ -108,7 +107,7 @@ class BadIPsAction(ActionBase):
|
|||
"""
|
||||
try:
|
||||
response = urlopen(
|
||||
cls.Request("/".join([cls.badips, "get", "categories"])))
|
||||
cls._Request("/".join([cls._badips, "get", "categories"])))
|
||||
except HTTPError as response:
|
||||
messages = json.loads(response.read().decode('utf-8'))
|
||||
self._logSys.error(
|
||||
|
@ -149,8 +148,8 @@ class BadIPsAction(ActionBase):
|
|||
Any issues with badips.com request.
|
||||
"""
|
||||
try:
|
||||
response = urlopen(cls.Request("?".join([
|
||||
"/".join([cls.badips, "get", "list", category, str(score)]),
|
||||
response = urlopen(cls._Request("?".join([
|
||||
"/".join([cls._badips, "get", "list", category, str(score)]),
|
||||
urlencode({'age': age})])))
|
||||
except HTTPError as response:
|
||||
messages = json.loads(response.read().decode('utf-8'))
|
||||
|
@ -332,8 +331,8 @@ class BadIPsAction(ActionBase):
|
|||
Any issues with badips.com request.
|
||||
"""
|
||||
try:
|
||||
response = urlopen(self.Request(
|
||||
"/".join([self.badips, "add", self.category, aInfo['ip']])))
|
||||
response = urlopen(self._Request(
|
||||
"/".join([self._badips, "add", self.category, aInfo['ip']])))
|
||||
except HTTPError as response:
|
||||
messages = json.loads(response.read().decode('utf-8'))
|
||||
self._logSys.error(
|
||||
|
|
|
@ -174,6 +174,12 @@ action_xarf = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(prot
|
|||
#
|
||||
action_blocklist_de = blocklist_de[email="%(sender)s", service=%(filter)s, apikey="%(blocklist_de_apikey)s"]
|
||||
|
||||
# Report ban via badips.com, and use as blacklist
|
||||
#
|
||||
# See BadIPsAction docstring in config/action.d/badips.py for
|
||||
# documentation for this action.
|
||||
#
|
||||
action_badips = badips.py[category="%(name)s", banaction="%(banaction)s"]
|
||||
|
||||
# Choose default action. To change, just override value of 'action' with the
|
||||
# interpolation to the chosen action shortcut (e.g. action_mw, action_mwl, etc) in jail.local
|
||||
|
|
Loading…
Reference in New Issue