From c160a47e51aa86283c6be9315c35bf3a9f6b68e4 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sat, 21 May 2016 15:25:57 -0700 Subject: [PATCH] warn users if rfile == outfile, refs #1117 --- mitmproxy/cmdline.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mitmproxy/cmdline.py b/mitmproxy/cmdline.py index da91e9523..8476f6f33 100644 --- a/mitmproxy/cmdline.py +++ b/mitmproxy/cmdline.py @@ -165,6 +165,18 @@ def get_common_options(options): raise configargparse.ArgumentTypeError(e.message) setheaders.append(p) + if options.outfile and options.outfile[0] == options.rfile: + if options.outfile[1] == "wb": + raise configargparse.ArgumentTypeError( + "Cannot use '{}' for both reading and writing flows. " + "Are you looking for --afile?".format(options.rfile) + ) + else: + raise configargparse.ArgumentTypeError( + "Cannot use '{}' for both reading and appending flows. " + "That would trigger an infinite loop." + ) + return dict( app=options.app, app_host=options.app_host,