diff --git a/common/protocol.py b/common/protocol.py index 01c0c984..e53d121b 100644 --- a/common/protocol.py +++ b/common/protocol.py @@ -30,19 +30,23 @@ import textwrap # 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 ", "sets logging level to . 0 is minimal, 4 is debug"], ["get loglevel", "gets the logging level"], ["set logtarget ", "sets logging target to . Can be STDOUT, STDERR, SYSLOG or a file"], ["get logtarget", "gets logging target"], -['', ''], +['', "Jail control", ""], ["add ", "creates using "], -['', ''], +["start ", "starts the jail "], +["stop ", "stops the jail . The jail is removed"], +["status ", "gets the current status of "], +['', "Jail configuration", ""], ["set idle on|off", "sets the idle state of "], ["set addignoreip ", "adds to the ignore list of "], ["set delignoreip ", "removes from the ignore list of "], @@ -64,7 +68,7 @@ protocol = [ ["set actioncheck ", "sets the check command of the action for "], ["set actionban ", "sets the ban command of the action for "], ["set actionunban ", "sets the unban command of the action for "], -['', ''], +['', "Jail information", ""], ["get logpath", "gets the list of the monitored files for "], ["get ignoreip", "gets the list of ignored IP addresses for "], ["get timeregex", "gets the regular expression used for the time detection for "], @@ -80,10 +84,6 @@ protocol = [ ["get actioncheck ", "gets the check command for the action for "], ["get actionban ", "gets the ban command for the action for "], ["get actionunban ", "gets the unban command for the action for "], -['', ''], -["start ", "starts the jail "], -["stop ", "stops the jail . The jail is removed"], -["status ", "gets the current status of "] ] ## @@ -94,14 +94,41 @@ def printFormatted(): 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 "| " + m[0] + " || || " + m[1] + print "|}" + +def __printWikiHeader(section, desc): + print + print "=== " + section + " ===" + print + print desc + print + print "{|" + print "| '''Command''' || || '''Description'''"