- Applied changes (command line options) from Yaroslav Halchenko

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@124 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.5
Cyril Jaquier 2005-07-08 10:01:04 +00:00
parent ebccfea6cb
commit 8e16185ef1
1 changed files with 19 additions and 6 deletions

View File

@ -40,8 +40,10 @@ logSys = log4py.Logger().get_instance()
logFwList = list() logFwList = list()
conf = dict() conf = dict()
def usage(): def dispUsage():
print "Usage: fail2ban [OPTIONS]" """ Prints Fail2Ban command line options and exits
"""
print "Usage: "+sys.argv[0]+" [OPTIONS]"
print print
print "Fail2Ban v"+version+" reads log file that contains password failure report" print "Fail2Ban v"+version+" reads log file that contains password failure report"
print "and bans the corresponding IP address using iptables." print "and bans the corresponding IP address using iptables."
@ -57,10 +59,17 @@ def usage():
print " -r <VALUE> allow a max of VALUE password failure" print " -r <VALUE> allow a max of VALUE password failure"
print " -t <TIME> ban IP for TIME seconds" print " -t <TIME> ban IP for TIME seconds"
print " -v verbose. Use twice for greater effect" print " -v verbose. Use twice for greater effect"
print " -V print software version"
print print
print "Report bugs to <lostcontrol@users.sourceforge.net>" print "Report bugs to <lostcontrol@users.sourceforge.net>"
sys.exit(0) sys.exit(0)
def dispVersion():
""" Prints Fail2Ban version and exits
"""
print sys.argv[0]+" "+version
sys.exit(0)
def checkForRoot(): def checkForRoot():
""" Check for root user. """ Check for root user.
""" """
@ -99,8 +108,10 @@ def getCmdLineOptions(optList):
""" Gets the command line options """ Gets the command line options
""" """
for opt in optList: for opt in optList:
if opt[0] == "-h": if opt[0] in ["-h", "--help"]:
usage() dispUsage()
if opt[0] in ["-V", "--version"]:
dispVersion()
if opt[0] == "-v": if opt[0] == "-v":
conf["verbose"] = conf["verbose"] + 1 conf["verbose"] = conf["verbose"] + 1
if opt[0] == "-b": if opt[0] == "-b":
@ -143,9 +154,11 @@ def main():
# Reads the command line options. # Reads the command line options.
try: try:
optList, args = getopt.getopt(sys.argv[1:], 'hvbdkc:l:t:i:r:p:') cmdOpts = 'hvVbdkc:l:t:i:r:p:'
cmdLongOpts = ['help','version']
optList, args = getopt.getopt(sys.argv[1:], cmdOpts, cmdLongOpts)
except getopt.GetoptError: except getopt.GetoptError:
usage() dispUsage()
# Pre-parsing of command line options for the -c option # Pre-parsing of command line options for the -c option
for opt in optList: for opt in optList: