diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-03-14 11:54:47 +1100 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-03-14 11:54:47 +1100 |
commit | 09e995ab5c78b8bd098e1330df7aa40972e0b1bb (patch) | |
tree | 987cca80305d1fbf8b0d5f424f5843478297abe2 /libpathod/pathoc.py | |
parent | 2e64d44aabc41ee93c0a682ce35b34a8716d3b8d (diff) | |
download | mitmproxy-09e995ab5c78b8bd098e1330df7aa40972e0b1bb.tar.gz mitmproxy-09e995ab5c78b8bd098e1330df7aa40972e0b1bb.tar.bz2 mitmproxy-09e995ab5c78b8bd098e1330df7aa40972e0b1bb.zip |
Improvements to pathoc repeat requests
- Pathoc will now keep trying if connections failed
- Add a -w option to specify a wait time between requests
Diffstat (limited to 'libpathod/pathoc.py')
-rw-r--r-- | libpathod/pathoc.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index e7aff520..d6b2c7a2 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -2,12 +2,15 @@ import sys import os import hashlib import random +import time + +import OpenSSL.crypto + from netlib import tcp, http, certutils import netlib.utils import language import utils -import OpenSSL.crypto class PathocError(Exception): @@ -226,9 +229,13 @@ def main(args): try: cnt = 0 while 1: + if cnt == args.repeat and args.repeat != 0: + break if trycount > args.memolimit: print >> sys.stderr, "Memo limit exceeded..." return + if args.wait and cnt != 0: + time.sleep(args.wait) cnt += 1 if args.random: @@ -262,7 +269,10 @@ def main(args): trycount = 0 try: p.connect(args.connect_to) - except (tcp.NetLibError, PathocError), v: + except tcp.NetLibError, v: + print >> sys.stderr, str(v) + continue + except PathocError, v: print >> sys.stderr, str(v) sys.exit(1) if args.timeout: @@ -281,7 +291,5 @@ def main(args): sys.stdout.flush() if ret and args.oneshot: sys.exit(0) - if cnt == args.repeat: - break except KeyboardInterrupt: pass |