From 956149c126c0500aa67604996ca310824b2f23a2 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 26 Oct 2014 18:16:47 +1300 Subject: [PATCH] --memo-limit - limit failed attempts to find new generated requests to N --- libpathod/cmdline.py | 4 ++++ libpathod/pathoc.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/libpathod/cmdline.py b/libpathod/cmdline.py index fe5eed687..4a2390ed9 100644 --- a/libpathod/cmdline.py +++ b/libpathod/cmdline.py @@ -34,6 +34,10 @@ def go_pathoc(): metavar = "HOST:PORT", help="Issue an HTTP CONNECT to connect to the specified host." ) + parser.add_argument( + "--memo-limit", dest='memolimit', default=5000, type=int, metavar="N", + help='Stop if we do not find a valid request after N attempts.' + ) parser.add_argument( "-m", dest='memo', action="store_true", default=False, help=""" diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index 0ff02b01f..e7aff5202 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -222,9 +222,14 @@ class Pathoc(tcp.TCPClient): def main(args): memo = set([]) + trycount = 0 try: cnt = 0 while 1: + if trycount > args.memolimit: + print >> sys.stderr, "Memo limit exceeded..." + return + cnt += 1 if args.random: playlist = [random.choice(args.requests)] @@ -251,8 +256,10 @@ def main(args): newlist.append(spec) playlist = newlist if not playlist: + trycount += 1 continue + trycount = 0 try: p.connect(args.connect_to) except (tcp.NetLibError, PathocError), v: