Browse Source

- 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 18 years ago
parent
commit
f8c0c60c2c
  1. 65
      protocol.py

65
protocol.py

@ -30,23 +30,33 @@ import textwrap
# Describes the protocol used to communicate with the server.
protocol = [
["start", "starts the server and the jails"],
["reload", "reloads the configuration"],
["stop", "stops all jails and terminate the server"],
["status", "gets the current status of the server"],
["ping", "tests if the server is alive"],
['', ''],
["set loglevel <LEVEL>", "sets logging level to <LEVEL>"],
["get loglevel", "gets the logging level"],
["set logtarget <TARGET>", "sets logging target to <TARGET>"],
["get logtarget", "gets logging target"],
['', ''],
["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>"],
['', ''],
["start <JAIL>", "starts <JAIL>"],
["stop <JAIL>", "stops <JAIL>. The jail is removed"],
["start", "starts the server and the jails"],
["reload", "reloads the configuration"],
["stop", "stops all jails and terminate the server"],
["status", "gets the current status of the server"],
["ping", "tests if the server is alive"],
['', ''],
["set loglevel <LEVEL>", "sets logging level to <LEVEL>"],
["get loglevel", "gets the logging level"],
["set logtarget <TARGET>", "sets logging target to <TARGET>"],
["get logtarget", "gets logging target"],
['', ''],
["add <JAIL> <BACKEND>", "creates <JAIL> using <BACKEND>"],
['', ''],
["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> 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>"]
]
@ -56,11 +66,16 @@ protocol = [
def printFormatted():
INDENT=4
FIRST=30
WIDTH=75
for command in [' ' * INDENT + m[0] +
"\n".join(textwrap.wrap(m[1], WIDTH - INDENT,
initial_indent=' ' * (FIRST - len(m[0])),
subsequent_indent=' ' * (FIRST + INDENT)))
for m in protocol]:
print command
MARGIN=35
WIDTH=40
for m in protocol:
if m[0] == '':
print
first = True
for n in textwrap.wrap(m[1], WIDTH):
if first:
n = ' ' * INDENT + m[0] + ' ' * (MARGIN - len(m[0])) + n
first = False
else:
n = ' ' * (INDENT + MARGIN) + n
print n

Loading…
Cancel
Save