From: <los...@us...> - 2006-12-15 23:02:13
|
Revision: 490 http://svn.sourceforge.net/fail2ban/?rev=490&view=rev Author: lostcontrol Date: 2006-12-15 15:02:12 -0800 (Fri, 15 Dec 2006) Log Message: ----------- - Added protocol output for Mediawiki Modified Paths: -------------- trunk/common/protocol.py Modified: trunk/common/protocol.py =================================================================== --- trunk/common/protocol.py 2006-12-14 21:20:03 UTC (rev 489) +++ trunk/common/protocol.py 2006-12-15 23:02:12 UTC (rev 490) @@ -30,19 +30,23 @@ # Describes the protocol used to communicate with the server. protocol = [ +['', "Basic", ""], ["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"], -['', ''], +['', "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>"], @@ -64,7 +68,7 @@ ["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> timeregex", "gets the regular expression used for the time detection for <JAIL>"], @@ -80,10 +84,6 @@ ["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>"], -['', ''], -["start <JAIL>", "starts the jail <JAIL>"], -["stop <JAIL>", "stops the jail <JAIL>. The jail is removed"], -["status <JAIL>", "gets the current status of <JAIL>"] ] ## @@ -94,14 +94,41 @@ INDENT=4 MARGIN=41 WIDTH=34 + firstHeading = False for m in protocol: - if m[0] == '': + if m[0] == '' and firstHeading: print + firstHeading = True first = True for n in textwrap.wrap(m[1], WIDTH): if first: - n = ' ' * INDENT + m[0] + ' ' * (MARGIN - len(m[0])) + n + line = ' ' * INDENT + m[0] + ' ' * (MARGIN - len(m[0])) + n first = False else: - n = ' ' * (INDENT + MARGIN) + n - print n + 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'''" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |