aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/dump.py
diff options
context:
space:
mode:
Diffstat (limited to 'mitmproxy/dump.py')
-rw-r--r--mitmproxy/dump.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py
index bfefb319..cf7aa5c9 100644
--- a/mitmproxy/dump.py
+++ b/mitmproxy/dump.py
@@ -12,6 +12,7 @@ from mitmproxy import exceptions
from mitmproxy import filt
from mitmproxy import flow
from mitmproxy import options
+from mitmproxy import builtins
from netlib import human
from netlib import tcp
from netlib import strutils
@@ -58,7 +59,8 @@ class Options(options.Options):
class DumpMaster(flow.FlowMaster):
def __init__(self, server, options, outfile=None):
- flow.FlowMaster.__init__(self, server, flow.State())
+ flow.FlowMaster.__init__(self, options, server, flow.State())
+ self.addons.add(*builtins.default_addons())
self.outfile = outfile
self.o = options
self.anticache = options.anticache
@@ -137,8 +139,8 @@ class DumpMaster(flow.FlowMaster):
self.add_event("Flow file corrupted.", "error")
raise DumpError(v)
- if self.o.app:
- self.start_app(self.o.app_host, self.o.app_port)
+ if self.options.app:
+ self.start_app(self.options.app_host, self.options.app_port)
def _readflow(self, paths):
"""
@@ -152,7 +154,7 @@ class DumpMaster(flow.FlowMaster):
def add_event(self, e, level="info"):
needed = dict(error=0, info=1, debug=2).get(level, 1)
- if self.o.verbosity >= needed:
+ if self.options.verbosity >= needed:
self.echo(
e,
fg="red" if level == "error" else None,
@@ -172,7 +174,7 @@ class DumpMaster(flow.FlowMaster):
click.secho(text, file=self.outfile, **style)
def _echo_message(self, message):
- if self.o.flow_detail >= 2 and hasattr(message, "headers"):
+ if self.options.flow_detail >= 2 and hasattr(message, "headers"):
headers = "\r\n".join(
"{}: {}".format(
click.style(strutils.bytes_to_escaped_str(k), fg="blue", bold=True),
@@ -180,7 +182,7 @@ class DumpMaster(flow.FlowMaster):
for k, v in message.headers.fields
)
self.echo(headers, indent=4)
- if self.o.flow_detail >= 3:
+ if self.options.flow_detail >= 3:
if message.content is None:
self.echo("(content missing)", indent=4)
elif message.content:
@@ -213,7 +215,7 @@ class DumpMaster(flow.FlowMaster):
for (style, text) in line:
yield click.style(text, **styles.get(style, {}))
- if self.o.flow_detail == 3:
+ if self.options.flow_detail == 3:
lines_to_echo = itertools.islice(lines, 70)
else:
lines_to_echo = lines
@@ -228,7 +230,7 @@ class DumpMaster(flow.FlowMaster):
if next(lines, None):
self.echo("(cut off)", indent=4, dim=True)
- if self.o.flow_detail >= 2:
+ if self.options.flow_detail >= 2:
self.echo("")
def _echo_request_line(self, flow):
@@ -302,7 +304,7 @@ class DumpMaster(flow.FlowMaster):
self.echo(line)
def echo_flow(self, f):
- if self.o.flow_detail == 0:
+ if self.options.flow_detail == 0:
return
if f.request:
@@ -350,7 +352,7 @@ class DumpMaster(flow.FlowMaster):
def tcp_message(self, f):
super(DumpMaster, self).tcp_message(f)
- if self.o.flow_detail == 0:
+ if self.options.flow_detail == 0:
return
message = f.messages[-1]
direction = "->" if message.from_client else "<-"
@@ -362,7 +364,7 @@ class DumpMaster(flow.FlowMaster):
self._echo_message(message)
def run(self): # pragma: no cover
- if self.o.rfile and not self.o.keepserving:
+ if self.options.rfile and not self.options.keepserving:
self.unload_scripts() # make sure to trigger script unload events.
return
super(DumpMaster, self).run()