From aefb30ea60255166a4d6b3da8e669a4e89485f6e Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 12 Mar 2014 22:13:00 +0100 Subject: [PATCH] restrict -e to mitmproxy only (not mitmdump) --- libmproxy/cmdline.py | 6 ------ libmproxy/console/flowlist.py | 2 +- libmproxy/dump.py | 8 +++----- libmproxy/script.py | 5 +++-- mitmproxy | 5 +++++ test/test_dump.py | 4 ++-- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/libmproxy/cmdline.py b/libmproxy/cmdline.py index c2911a6b7..6c0b1ae84 100644 --- a/libmproxy/cmdline.py +++ b/libmproxy/cmdline.py @@ -161,7 +161,6 @@ def get_common_options(options): anticache = options.anticache, anticomp = options.anticomp, client_replay = options.client_replay, - eventlog = options.eventlog, kill = options.kill, no_server = options.no_server, refresh_server_playback = not options.norefresh, @@ -196,11 +195,6 @@ def common_options(parser): action="store", type = str, dest="confdir", default='~/.mitmproxy', help = "Configuration directory. (~/.mitmproxy)" ) - parser.add_argument( - "-e", - action="store_true", dest="eventlog", - help="Show event log." - ) parser.add_argument( "-n", action="store_true", dest="no_server", diff --git a/libmproxy/console/flowlist.py b/libmproxy/console/flowlist.py index deddae608..e03301712 100644 --- a/libmproxy/console/flowlist.py +++ b/libmproxy/console/flowlist.py @@ -69,7 +69,7 @@ class BodyPile(urwid.Pile): else: self.widget_list[1].header = self.inactive_header key = None - elif key == "v": + elif key == "e": self.master.toggle_eventlog() key = None diff --git a/libmproxy/dump.py b/libmproxy/dump.py index 6573d97db..c200e50ec 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -15,7 +15,6 @@ class Options(object): "anticache", "anticomp", "client_replay", - "eventlog", "keepserving", "kill", "no_server", @@ -66,7 +65,6 @@ class DumpMaster(flow.FlowMaster): self.o = options self.anticache = options.anticache self.anticomp = options.anticomp - self.eventlog = options.eventlog self.showhost = options.showhost self.refresh_server_playback = options.refresh_server_playback @@ -142,9 +140,9 @@ class DumpMaster(flow.FlowMaster): return flows def add_event(self, e, level="info"): - if self.eventlog: - print >> self.outfile, e - self.outfile.flush() + #FIXME refactor_loglevel + print >> self.outfile, e + self.outfile.flush() def indent(self, n, t): l = str(t).strip().split("\n") diff --git a/libmproxy/script.py b/libmproxy/script.py index 9638fdecc..bafa8ba93 100644 --- a/libmproxy/script.py +++ b/libmproxy/script.py @@ -15,9 +15,10 @@ class ScriptContext: Logs an event. How this is handled depends on the front-end. mitmdump will display - events if the eventlog flag ("-e") was passed. mitmproxy sends - output to the eventlog for display ("v" keyboard shortcut). + events if the v flag ("-e") was passed. mitmproxy sends + output to the eventlog for display ("e" keyboard shortcut). """ + #FIXME refactor_loglevel self._master.add_event(*args, **kwargs) def duplicate_flow(self, f): diff --git a/mitmproxy b/mitmproxy index 934d17725..9d6fb3740 100755 --- a/mitmproxy +++ b/mitmproxy @@ -23,6 +23,11 @@ if __name__ == '__main__': action="store", dest="palette", help="Select color palette: " + ", ".join(palettes.palettes.keys()) ) + parser.add_argument( + "-e", + action="store_true", dest="eventlog", + help="Show event log." + ) group = parser.add_argument_group( diff --git a/test/test_dump.py b/test/test_dump.py index 0f7d9bea0..b723c3e08 100644 --- a/test/test_dump.py +++ b/test/test_dump.py @@ -127,7 +127,7 @@ class TestDumpMaster: def test_basic(self): for i in (1, 2, 3): - assert "GET" in self._dummy_cycle(1, "~s", "", verbosity=i, eventlog=True) + assert "GET" in self._dummy_cycle(1, "~s", "", verbosity=i) assert "GET" in self._dummy_cycle(1, "~s", "\x00\x00\x00", verbosity=i) assert "GET" in self._dummy_cycle(1, "~s", "ascii", verbosity=i) @@ -150,7 +150,7 @@ class TestDumpMaster: def test_script(self): ret = self._dummy_cycle( 1, None, "", - scripts=[tutils.test_data.path("scripts/all.py")], verbosity=0, eventlog=True + scripts=[tutils.test_data.path("scripts/all.py")], verbosity=0 ) assert "XCLIENTCONNECT" in ret assert "XSERVERCONNECT" in ret