mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-06-19 04:56:19 +00:00
following commits were squashed from feature branch use_dns commit068c105eb5Author: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 22:19:04 2012 -0500 Prevent warning when IP is read from log commit635ed36a8cAuthor: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 22:17:08 2012 -0500 Removed logDebug commit24656d2812Merge:7957fbec429f5cAuthor: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 21:13:11 2012 -0500 Merge branch 'enh/use_dns' of github:leeclemens/fail2ban into enh/use_dns Conflicts: testcases/filtertestcase.py commit7957fbe821Author: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 21:09:58 2012 -0500 filtertestcase fixes from yarikoptic commit6ce9d04640Author: Yaroslav Halchenko <debian@onerussian.com> Date: Tue Jan 10 19:26:05 2012 -0500 RF: for consistency use_dns -> usedns I guess it was might fault of inconsistency suggesting that name. Other options/commands do not have _ in the names, so let it be consistent with the rest for now commitcfb2c75b49Author: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 19:18:41 2012 -0500 Updated DNSUtilsTests to test use_dns and added positive test to testTextToIp commitf6186eff14Author: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 19:02:04 2012 -0500 Changed wording of 'DNS Reverse lookup used' message commit82c62d29dcAuthor: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 18:53:17 2012 -0500 Removed extraneous "n" commitdc0ae21932Author: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 23:07:59 2012 -0500 ENH: use_dns - removed debugging statements commit594e25818cAuthor: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 22:53:39 2012 -0500 Added use_dns protocol to set and get per jail during runtime commit48ff80ffacAuthor: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 22:41:18 2012 -0500 Completed use_dns for initial startup - with debugging statements commit0bdab4c2d7Author: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 20:05:35 2012 -0500 ENH: Added use_dns option commit6d6b734ea5Author: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 20:01:34 2012 -0500 ENH: Added use_dns option commit11ad2b6125Author: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 19:17:30 2012 -0500 Added useDns flag to testcase commitb48fa9b6afAuthor: Lee Clemens <java@leeclemens.net> Date: Sun Jan 8 15:13:27 2012 -0500 Added use_dns option in jail.conf commitc429f5c91aMerge:4b18afb0021906Author: leeclemens <java@leeclemens.net> Date: Tue Jan 10 16:32:22 2012 -0800 Merge pull request #3 from yarikoptic/enh/use_dns let's be consistent ;-) commit0021906358Author: Yaroslav Halchenko <debian@onerussian.com> Date: Tue Jan 10 19:26:05 2012 -0500 RF: for consistency use_dns -> usedns I guess it was might fault of inconsistency suggesting that name. Other options/commands do not have _ in the names, so let it be consistent with the rest for now commit4b18afb28aAuthor: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 19:18:41 2012 -0500 Updated DNSUtilsTests to test use_dns and added positive test to testTextToIp commit4fae37e46fAuthor: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 19:02:04 2012 -0500 Changed wording of 'DNS Reverse lookup used' message commite94806ce48Author: Lee Clemens <java@leeclemens.net> Date: Tue Jan 10 18:53:17 2012 -0500 Removed extraneous "n" commit4d30c52907Author: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 23:07:59 2012 -0500 ENH: use_dns - removed debugging statements commit76696d452aAuthor: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 22:53:39 2012 -0500 Added use_dns protocol to set and get per jail during runtime commit0631618087Author: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 22:41:18 2012 -0500 Completed use_dns for initial startup - with debugging statements commitd23d495547Author: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 20:05:35 2012 -0500 ENH: Added use_dns option commit9538553bc5Author: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 20:01:34 2012 -0500 ENH: Added use_dns option commitae1e857e53Author: Lee Clemens <java@leeclemens.net> Date: Mon Jan 9 19:17:30 2012 -0500 Added useDns flag to testcase commitace43eb941Author: Lee Clemens <java@leeclemens.net> Date: Sun Jan 8 15:13:27 2012 -0500 Added use_dns option in jail.conf
139 lines
6.2 KiB
Python
139 lines
6.2 KiB
Python
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*-
|
|
# vi: set ft=python sts=4 ts=4 sw=4 noet :
|
|
|
|
# This file is part of Fail2Ban.
|
|
#
|
|
# Fail2Ban is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Fail2Ban is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Fail2Ban; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
# Author: Cyril Jaquier
|
|
#
|
|
# $Revision$
|
|
|
|
__author__ = "Cyril Jaquier"
|
|
__version__ = "$Revision$"
|
|
__date__ = "$Date$"
|
|
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
|
__license__ = "GPL"
|
|
|
|
import textwrap
|
|
|
|
##
|
|
# Describes the protocol used to communicate with the server.
|
|
|
|
protocol = [
|
|
['', "BASIC", ""],
|
|
["start", "starts the server and the jails"],
|
|
["reload", "reloads the configuration"],
|
|
["reload <JAIL>", "reloads the jail <JAIL>"],
|
|
["stop", "stops all jails and terminate the server"],
|
|
["status", "gets the current status of the server"],
|
|
["ping", "tests if the server is alive"],
|
|
['', "LOGGING", ""],
|
|
["set loglevel <LEVEL>", "sets logging level to <LEVEL>. 0 is minimal, 4 is debug"],
|
|
["get loglevel", "gets the logging level"],
|
|
["set logtarget <TARGET>", "sets logging target to <TARGET>. Can be STDOUT, STDERR, SYSLOG or a file"],
|
|
["get logtarget", "gets logging target"],
|
|
['', "JAIL CONTROL", ""],
|
|
["add <JAIL> <BACKEND>", "creates <JAIL> using <BACKEND>"],
|
|
["start <JAIL>", "starts the jail <JAIL>"],
|
|
["stop <JAIL>", "stops the jail <JAIL>. The jail is removed"],
|
|
["status <JAIL>", "gets the current status of <JAIL>"],
|
|
['', "JAIL CONFIGURATION", ""],
|
|
["set <JAIL> idle on|off", "sets the idle state of <JAIL>"],
|
|
["set <JAIL> addignoreip <IP>", "adds <IP> to the ignore list of <JAIL>"],
|
|
["set <JAIL> delignoreip <IP>", "removes <IP> from the ignore list of <JAIL>"],
|
|
["set <JAIL> addlogpath <FILE>", "adds <FILE> to the monitoring list of <JAIL>"],
|
|
["set <JAIL> dellogpath <FILE>", "removes <FILE> from the monitoring list of <JAIL>"],
|
|
["set <JAIL> addfailregex <REGEX>", "adds the regular expression <REGEX> which must match failures for <JAIL>"],
|
|
["set <JAIL> delfailregex <INDEX>", "removes the regular expression at <INDEX> for failregex"],
|
|
["set <JAIL> addignoreregex <REGEX>", "adds the regular expression <REGEX> which should match pattern to exclude for <JAIL>"],
|
|
["set <JAIL> delignoreregex <INDEX>", "removes the regular expression at <INDEX> for ignoreregex"],
|
|
["set <JAIL> findtime <TIME>", "sets the number of seconds <TIME> for which the filter will look back for <JAIL>"],
|
|
["set <JAIL> bantime <TIME>", "sets the number of seconds <TIME> a host will be banned for <JAIL>"],
|
|
["set <JAIL> usedns <VALUE>", "sets the usedns mode for <JAIL>"],
|
|
["set <JAIL> banip <IP>", "manually Ban <IP> for <JAIL>"],
|
|
["set <JAIL> maxretry <RETRY>", "sets the number of failures <RETRY> before banning the host for <JAIL>"],
|
|
["set <JAIL> addaction <ACT>", "adds a new action named <NAME> for <JAIL>"],
|
|
["set <JAIL> delaction <ACT>", "removes the action <NAME> from <JAIL>"],
|
|
["set <JAIL> setcinfo <ACT> <KEY> <VALUE>", "sets <VALUE> for <KEY> of the action <NAME> for <JAIL>"],
|
|
["set <JAIL> delcinfo <ACT> <KEY>", "removes <KEY> for the action <NAME> for <JAIL>"],
|
|
["set <JAIL> actionstart <ACT> <CMD>", "sets the start command <CMD> of the action <ACT> for <JAIL>"],
|
|
["set <JAIL> actionstop <ACT> <CMD>", "sets the stop command <CMD> of the action <ACT> for <JAIL>"],
|
|
["set <JAIL> actioncheck <ACT> <CMD>", "sets the check command <CMD> of the action <ACT> for <JAIL>"],
|
|
["set <JAIL> actionban <ACT> <CMD>", "sets the ban command <CMD> of the action <ACT> for <JAIL>"],
|
|
["set <JAIL> actionunban <ACT> <CMD>", "sets the unban command <CMD> of the action <ACT> for <JAIL>"],
|
|
['', "JAIL INFORMATION", ""],
|
|
["get <JAIL> logpath", "gets the list of the monitored files for <JAIL>"],
|
|
["get <JAIL> ignoreip", "gets the list of ignored IP addresses for <JAIL>"],
|
|
["get <JAIL> failregex", "gets the list of regular expressions which matches the failures for <JAIL>"],
|
|
["get <JAIL> ignoreregex", "gets the list of regular expressions which matches patterns to ignore for <JAIL>"],
|
|
["get <JAIL> findtime", "gets the time for which the filter will look back for failures for <JAIL>"],
|
|
["get <JAIL> bantime", "gets the time a host is banned for <JAIL>"],
|
|
["get <JAIL> usedns", "gets the usedns setting for <JAIL>"],
|
|
["get <JAIL> maxretry", "gets the number of failures allowed for <JAIL>"],
|
|
["get <JAIL> addaction", "gets the last action which has been added for <JAIL>"],
|
|
["get <JAIL> actionstart <ACT>", "gets the start command for the action <ACT> for <JAIL>"],
|
|
["get <JAIL> actionstop <ACT>", "gets the stop command for the action <ACT> for <JAIL>"],
|
|
["get <JAIL> actioncheck <ACT>", "gets the check command for the action <ACT> for <JAIL>"],
|
|
["get <JAIL> actionban <ACT>", "gets the ban command for the action <ACT> for <JAIL>"],
|
|
["get <JAIL> actionunban <ACT>", "gets the unban command for the action <ACT> for <JAIL>"],
|
|
]
|
|
|
|
##
|
|
# Prints the protocol in a "man" format. This is used for the
|
|
# "-h" output of fail2ban-client.
|
|
|
|
def printFormatted():
|
|
INDENT=4
|
|
MARGIN=41
|
|
WIDTH=34
|
|
firstHeading = False
|
|
for m in protocol:
|
|
if m[0] == '' and firstHeading:
|
|
print
|
|
firstHeading = True
|
|
first = True
|
|
for n in textwrap.wrap(m[1], WIDTH):
|
|
if first:
|
|
line = ' ' * INDENT + m[0] + ' ' * (MARGIN - len(m[0])) + n
|
|
first = False
|
|
else:
|
|
line = ' ' * (INDENT + MARGIN) + n
|
|
print line
|
|
|
|
##
|
|
# Prints the protocol in a "mediawiki" format.
|
|
|
|
def printWiki():
|
|
firstHeading = False
|
|
for m in protocol:
|
|
if m[0] == '':
|
|
if firstHeading:
|
|
print "|}"
|
|
__printWikiHeader(m[1], m[2])
|
|
firstHeading = True
|
|
else:
|
|
print "|-"
|
|
print "| <span style=\"white-space:nowrap;\"><tt>" + m[0] + "</tt></span> || || " + m[1]
|
|
print "|}"
|
|
|
|
def __printWikiHeader(section, desc):
|
|
print
|
|
print "=== " + section + " ==="
|
|
print
|
|
print desc
|
|
print
|
|
print "{|"
|
|
print "| '''Command''' || || '''Description'''"
|