restrict -e to mitmproxy only (not mitmdump)

This commit is contained in:
Maximilian Hils 2014-03-12 22:13:00 +01:00
parent 14db30080f
commit aefb30ea60
6 changed files with 14 additions and 16 deletions

View File

@ -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",

View File

@ -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

View File

@ -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")

View File

@ -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):

View File

@ -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(

View File

@ -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