From 14a3e0073fe3a9b8103801d400d293186a9dc7f9 Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Thu, 11 Dec 2014 15:21:33 -0300 Subject: append file mode for saving flows merged to master --- libmproxy/cmdline.py | 14 ++++++++++---- libmproxy/dump.py | 8 ++++---- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'libmproxy') diff --git a/libmproxy/cmdline.py b/libmproxy/cmdline.py index b892f1fd..bf5add33 100644 --- a/libmproxy/cmdline.py +++ b/libmproxy/cmdline.py @@ -179,7 +179,7 @@ def get_common_options(options): stickyauth=stickyauth, stream_large_bodies=stream_large_bodies, showhost=options.showhost, - wfile=options.wfile, + outfile=options.outfile, verbosity=options.verbose, nopop=options.nopop, replay_ignore_content = options.replay_ignore_content, @@ -249,11 +249,17 @@ def common_options(parser): action="store_const", dest="verbose", default=1, const=2, help="Increase event log verbosity." ) - parser.add_argument( + outfile = parser.add_mutually_exclusive_group() + outfile.add_argument( "-w", "--wfile", - action="store", dest="wfile", default=None, + action="store", dest="outfile", type=lambda f: (f, "wb"), help="Write flows to file." ) + outfile.add_argument( + "-a", "--afile", + action="store", dest="outfile", type=lambda f: (f, "ab"), + help="Append flows to file." + ) parser.add_argument( "-z", "--anticomp", action="store_true", dest="anticomp", default=False, @@ -371,7 +377,7 @@ def common_options(parser): group = parser.add_argument_group("Onboarding App") group.add_argument( - "-a", "--noapp", + "--noapp", action="store_false", dest="app", default=True, help="Disable the mitmproxy onboarding app." ) diff --git a/libmproxy/dump.py b/libmproxy/dump.py index 0d9432c9..8f260745 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -36,7 +36,7 @@ class Options(object): "stickyauth", "stream_large_bodies", "verbosity", - "wfile", + "outfile", "replay_ignore_content", "replay_ignore_params", ] @@ -92,10 +92,10 @@ class DumpMaster(flow.FlowMaster): if options.stickyauth: self.set_stickyauth(options.stickyauth) - if options.wfile: - path = os.path.expanduser(options.wfile) + if options.outfile: + path = os.path.expanduser(options.outfile[0]) try: - f = file(path, "wb") + f = file(path, options.outfile[1]) self.start_stream(f, self.filt) except IOError, v: raise DumpError(v.strerror) -- cgit v1.2.3