- Fixed printFormatted

- Added more commands

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@463 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.x
Cyril Jaquier 2006-11-13 22:17:20 +00:00
parent 994fefcd4a
commit f8c0c60c2c
1 changed files with 40 additions and 25 deletions

View File

@ -30,23 +30,33 @@ import textwrap
# Describes the protocol used to communicate with the server. # Describes the protocol used to communicate with the server.
protocol = [ protocol = [
["start", "starts the server and the jails"], ["start", "starts the server and the jails"],
["reload", "reloads the configuration"], ["reload", "reloads the configuration"],
["stop", "stops all jails and terminate the server"], ["stop", "stops all jails and terminate the server"],
["status", "gets the current status of the server"], ["status", "gets the current status of the server"],
["ping", "tests if the server is alive"], ["ping", "tests if the server is alive"],
['', ''], ['', ''],
["set loglevel <LEVEL>", "sets logging level to <LEVEL>"], ["set loglevel <LEVEL>", "sets logging level to <LEVEL>"],
["get loglevel", "gets the logging level"], ["get loglevel", "gets the logging level"],
["set logtarget <TARGET>", "sets logging target to <TARGET>"], ["set logtarget <TARGET>", "sets logging target to <TARGET>"],
["get logtarget", "gets logging target"], ["get logtarget", "gets logging target"],
['', ''], ['', ''],
["add <JAIL> <BACKEND>", "creates <JAIL> using <BACKEND>"], ["add <JAIL> <BACKEND>", "creates <JAIL> using <BACKEND>"],
["set <JAIL> <CMD>", "sets the <CMD> value for <JAIL>"], ['', ''],
["get <JAIL> <CMD>", "gets the <CMD> value for <JAIL>"], ["set <JAIL> idle on|off", "sets the idle state of <JAIL>"],
['', ''], ["set <JAIL> addignoreip <IP>", "adds <IP> to the ignore list of <JAIL>"],
["start <JAIL>", "starts <JAIL>"], ["set <JAIL> delignoreip <IP>", "removes <IP> from the ignore list of <JAIL>"],
["stop <JAIL>", "stops <JAIL>. The jail is removed"], ["set <JAIL> addlogpath <FILE>", "adds <FILE> to the monitoring list of <JAIL>"],
["set <JAIL> dellogpath <FILE>", "removes <FILE> to the monitoring list of <JAIL>"],
["set <JAIL> timeregex <REGEX>", "sets the regular expression <REGEX> to match the date format for <JAIL>"],
["set <JAIL> timepattern <PATTERN>", "sets the pattern <PATTERN> to match the date format for <JAIL>"],
["set <JAIL> failregex <REGEX>", "sets the regular expression <REGEX> which must match failures for <JAIL>"],
["set <JAIL> ignoreregex <REGEX>", "sets the regular expression <REGEX> which should match pattern to exclude for <JAIL>"],
['', ''],
["get <JAIL> <CMD>", "gets the <CMD> value for <JAIL>"],
['', ''],
["start <JAIL>", "starts <JAIL>"],
["stop <JAIL>", "stops <JAIL>. The jail is removed"],
["status <JAIL>", "gets the current status of <JAIL>"] ["status <JAIL>", "gets the current status of <JAIL>"]
] ]
@ -56,11 +66,16 @@ protocol = [
def printFormatted(): def printFormatted():
INDENT=4 INDENT=4
FIRST=30 MARGIN=35
WIDTH=75 WIDTH=40
for command in [' ' * INDENT + m[0] + for m in protocol:
"\n".join(textwrap.wrap(m[1], WIDTH - INDENT, if m[0] == '':
initial_indent=' ' * (FIRST - len(m[0])), print
subsequent_indent=' ' * (FIRST + INDENT))) first = True
for m in protocol]: for n in textwrap.wrap(m[1], WIDTH):
print command if first:
n = ' ' * INDENT + m[0] + ' ' * (MARGIN - len(m[0])) + n
first = False
else:
n = ' ' * (INDENT + MARGIN) + n
print n