mirror of https://github.com/fail2ban/fail2ban
- Removed debug option
- Added SMTP authentification support - Changed syslog output to a more standard format git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@231 a942ae1a-1317-0410-a47c-b1dcaea8d6050.6
parent
79318b3549
commit
1044b82e12
25
fail2ban.py
25
fail2ban.py
|
@ -56,7 +56,6 @@ def dispUsage():
|
||||||
print "and bans the corresponding IP addresses using firewall rules."
|
print "and bans the corresponding IP addresses using firewall rules."
|
||||||
print
|
print
|
||||||
print " -b start in background"
|
print " -b start in background"
|
||||||
print " -d start in debug mode"
|
|
||||||
print " -c <FILE> read configuration file FILE"
|
print " -c <FILE> read configuration file FILE"
|
||||||
print " -p <FILE> create PID lock in FILE"
|
print " -p <FILE> create PID lock in FILE"
|
||||||
print " -h display this help message"
|
print " -h display this help message"
|
||||||
|
@ -186,6 +185,7 @@ def main():
|
||||||
stdout.setFormatter(formatter)
|
stdout.setFormatter(formatter)
|
||||||
|
|
||||||
conf["kill"] = False
|
conf["kill"] = False
|
||||||
|
conf["debug"] = False
|
||||||
conf["verbose"] = 0
|
conf["verbose"] = 0
|
||||||
conf["conffile"] = "/etc/fail2ban.conf"
|
conf["conffile"] = "/etc/fail2ban.conf"
|
||||||
|
|
||||||
|
@ -216,7 +216,6 @@ def main():
|
||||||
["str", "logtargets", "/var/log/fail2ban.log"],
|
["str", "logtargets", "/var/log/fail2ban.log"],
|
||||||
["str", "syslog-target", "/dev/log"],
|
["str", "syslog-target", "/dev/log"],
|
||||||
["int", "syslog-facility", 1],
|
["int", "syslog-facility", 1],
|
||||||
["bool", "debug", False],
|
|
||||||
["str", "pidlock", "/var/run/fail2ban.pid"],
|
["str", "pidlock", "/var/run/fail2ban.pid"],
|
||||||
["int", "maxfailures", 5],
|
["int", "maxfailures", 5],
|
||||||
["int", "bantime", 600],
|
["int", "bantime", 600],
|
||||||
|
@ -294,8 +293,8 @@ def main():
|
||||||
port = int(syslogtargets[3])
|
port = int(syslogtargets[3])
|
||||||
syslogtarget = (syslogtargets[1], port)
|
syslogtarget = (syslogtargets[1], port)
|
||||||
hdlr = logging.handlers.SysLogHandler(syslogtarget, facility)
|
hdlr = logging.handlers.SysLogHandler(syslogtarget, facility)
|
||||||
tformatter = logging.Formatter("fail2ban[%(process)d]: " +
|
tformatter = logging.Formatter("%(asctime)s %(name)s " +
|
||||||
formatterstring);
|
formatterstring, "%b %e %T");
|
||||||
else:
|
else:
|
||||||
# Target should be a file
|
# Target should be a file
|
||||||
try:
|
try:
|
||||||
|
@ -315,14 +314,14 @@ def main():
|
||||||
logSys.setLevel(logging.INFO)
|
logSys.setLevel(logging.INFO)
|
||||||
elif conf["verbose"] > 1:
|
elif conf["verbose"] > 1:
|
||||||
logSys.setLevel(logging.DEBUG)
|
logSys.setLevel(logging.DEBUG)
|
||||||
|
if conf["verbose"] > 2:
|
||||||
# Set debug log level
|
formatterstring = ('%(levelname)s: [%(filename)s (%(lineno)d)] ' +
|
||||||
if conf["debug"]:
|
|
||||||
logSys.setLevel(logging.DEBUG)
|
|
||||||
formatterstring = ('%(levelname)s: [%(filename)s (%(lineno)d)] ' +
|
|
||||||
'%(message)s')
|
'%(message)s')
|
||||||
formatter = logging.Formatter("%(asctime)s " + formatterstring)
|
formatter = logging.Formatter("%(asctime)s " + formatterstring)
|
||||||
stdout.setFormatter(formatter)
|
stdout.setFormatter(formatter)
|
||||||
|
|
||||||
|
# Debug mode. Should only be used by developers
|
||||||
|
if conf["debug"]:
|
||||||
logSys.warn("DEBUG MODE: FIREWALL COMMANDS ARE _NOT_ EXECUTED BUT " +
|
logSys.warn("DEBUG MODE: FIREWALL COMMANDS ARE _NOT_ EXECUTED BUT " +
|
||||||
"ONLY DISPLAYED IN THE LOG MESSAGES")
|
"ONLY DISPLAYED IN THE LOG MESSAGES")
|
||||||
|
|
||||||
|
@ -358,6 +357,8 @@ def main():
|
||||||
["int", "port", "25"],
|
["int", "port", "25"],
|
||||||
["str", "from", "root"],
|
["str", "from", "root"],
|
||||||
["str", "to", "root"],
|
["str", "to", "root"],
|
||||||
|
["str", "user", ''],
|
||||||
|
["str", "password", ''],
|
||||||
["bool", "localtime", False],
|
["bool", "localtime", False],
|
||||||
["str", "subject", "[Fail2Ban] Banned <ip>"],
|
["str", "subject", "[Fail2Ban] Banned <ip>"],
|
||||||
["str", "message", "Fail2Ban notification"])
|
["str", "message", "Fail2Ban notification"])
|
||||||
|
@ -370,6 +371,8 @@ def main():
|
||||||
logSys.debug("Mail enabled")
|
logSys.debug("Mail enabled")
|
||||||
mail = Mail(mailConf["host"], mailConf["port"])
|
mail = Mail(mailConf["host"], mailConf["port"])
|
||||||
mail.setFromAddr(mailConf["from"])
|
mail.setFromAddr(mailConf["from"])
|
||||||
|
mail.setUser(mailConf["user"])
|
||||||
|
mail.setPassword(mailConf["password"])
|
||||||
mail.setToAddr(mailConf["to"])
|
mail.setToAddr(mailConf["to"])
|
||||||
mail.setLocalTimeFlag(mailConf["localtime"])
|
mail.setLocalTimeFlag(mailConf["localtime"])
|
||||||
logSys.debug("to: " + mailConf["to"] + " from: " + mailConf["from"])
|
logSys.debug("to: " + mailConf["to"] + " from: " + mailConf["from"])
|
||||||
|
|
Loading…
Reference in New Issue