mirror of https://github.com/fail2ban/fail2ban
amend to fix fail2ban-version: correct user-agent for badips.py "Fail2Ban/ver", changeable within jail/config now;
parent
cf334421bd
commit
ac31121432
|
@ -21,7 +21,6 @@ import sys
|
||||||
if sys.version_info < (2, 7):
|
if sys.version_info < (2, 7):
|
||||||
raise ImportError("badips.py action requires Python >= 2.7")
|
raise ImportError("badips.py action requires Python >= 2.7")
|
||||||
import json
|
import json
|
||||||
from functools import partial
|
|
||||||
import threading
|
import threading
|
||||||
import logging
|
import logging
|
||||||
if sys.version_info >= (3, ):
|
if sys.version_info >= (3, ):
|
||||||
|
@ -72,6 +71,9 @@ class BadIPsAction(ActionBase):
|
||||||
updateperiod : int, optional
|
updateperiod : int, optional
|
||||||
Time in seconds between updating bad IPs blacklist.
|
Time in seconds between updating bad IPs blacklist.
|
||||||
Default 900 (15 minutes)
|
Default 900 (15 minutes)
|
||||||
|
agent : str, optional
|
||||||
|
User agent transmitted to server.
|
||||||
|
Default `Fail2Ban/ver.`
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
------
|
------
|
||||||
|
@ -80,13 +82,14 @@ class BadIPsAction(ActionBase):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_badips = "http://www.badips.com"
|
_badips = "http://www.badips.com"
|
||||||
_Request = partial(
|
def _Request(self, url, **argv):
|
||||||
Request, headers={'User-Agent': "Fail2Ban %s" % f2bVersion})
|
return Request(url, headers={'User-Agent': self.agent}, **argv)
|
||||||
|
|
||||||
def __init__(self, jail, name, category, score=3, age="24h", key=None,
|
def __init__(self, jail, name, category, score=3, age="24h", key=None,
|
||||||
banaction=None, bancategory=None, bankey=None, updateperiod=900):
|
banaction=None, bancategory=None, bankey=None, updateperiod=900, agent=None):
|
||||||
super(BadIPsAction, self).__init__(jail, name)
|
super(BadIPsAction, self).__init__(jail, name)
|
||||||
|
|
||||||
|
self.agent = agent if agent is not None else ("Fail2Ban/%s" % f2bVersion)
|
||||||
self.category = category
|
self.category = category
|
||||||
self.score = score
|
self.score = score
|
||||||
self.age = age
|
self.age = age
|
||||||
|
|
Loading…
Reference in New Issue