From e608d10f455550b8afd09217f0ecf344a0bdc814 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 3 Mar 2013 12:26:20 +1300 Subject: Remove __slots__ to make it possible to inherit from Options classes. --- libmproxy/dump.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libmproxy/dump.py') diff --git a/libmproxy/dump.py b/libmproxy/dump.py index 3c7eee71..3a315409 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -21,7 +21,7 @@ class DumpError(Exception): pass class Options(object): - __slots__ = [ + attributes = [ "anticache", "anticomp", "client_replay", @@ -45,7 +45,7 @@ class Options(object): def __init__(self, **kwargs): for k, v in kwargs.items(): setattr(self, k, v) - for i in self.__slots__: + for i in self.attributes: if not hasattr(self, i): setattr(self, i, None) -- cgit v1.2.3 From cfb5ba89ce96594b2f8d51f27c9b2ee41ecf18e5 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 14 Mar 2013 09:19:43 +1300 Subject: Introduce a filtered flow writer, and use it in dump.py Fixes #104 --- libmproxy/dump.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libmproxy/dump.py') diff --git a/libmproxy/dump.py b/libmproxy/dump.py index 3a315409..d716e433 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -93,7 +93,7 @@ class DumpMaster(flow.FlowMaster): path = os.path.expanduser(options.wfile) try: f = file(path, "wb") - self.start_stream(f) + self.start_stream(f, self.filt) except IOError, v: raise DumpError(v.strerror) @@ -155,6 +155,7 @@ class DumpMaster(flow.FlowMaster): return "\n".join(" "*n + i for i in l) def _process_flow(self, f): + self.state.delete_flow(f) if self.filt and not f.match(self.filt): return @@ -198,7 +199,6 @@ class DumpMaster(flow.FlowMaster): print >> self.outfile, "\n" if self.o.verbosity: self.outfile.flush() - self.state.delete_flow(f) def handle_log(self, l): self.add_event(l.msg) -- cgit v1.2.3 From e50da8164fb4bd3b561846181b3a36df06e8d577 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 17 Mar 2013 17:43:31 +1300 Subject: Enable --host option for mitmdump --- libmproxy/dump.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libmproxy/dump.py') diff --git a/libmproxy/dump.py b/libmproxy/dump.py index d716e433..2e0e62d9 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -57,12 +57,12 @@ def str_response(resp): return r -def str_request(req): +def str_request(req, showhost): if req.client_conn: c = req.client_conn.address[0] else: c = "[replay]" - r = "%s %s %s"%(c, req.method, req.get_url()) + r = "%s %s %s"%(c, req.method, req.get_url(showhost)) if req.stickycookie: r = "[stickycookie] " + r return r @@ -76,6 +76,7 @@ class DumpMaster(flow.FlowMaster): self.anticache = options.anticache self.anticomp = options.anticomp self.eventlog = options.eventlog + self.showhost = options.showhost self.refresh_server_playback = options.refresh_server_playback if filtstr: @@ -179,16 +180,16 @@ class DumpMaster(flow.FlowMaster): result = " << %s"%f.error.msg if self.o.verbosity == 1: - print >> self.outfile, str_request(f.request) + print >> self.outfile, str_request(f.request, self.showhost) print >> self.outfile, result elif self.o.verbosity == 2: - print >> self.outfile, str_request(f.request) + print >> self.outfile, str_request(f.request, self.showhost) print >> self.outfile, self.indent(4, f.request.headers) print >> self.outfile print >> self.outfile, result print >> self.outfile, "\n" elif self.o.verbosity >= 3: - print >> self.outfile, str_request(f.request) + print >> self.outfile, str_request(f.request, self.showhost) print >> self.outfile, self.indent(4, f.request.headers) if utils.isBin(f.request.content): print >> self.outfile, self.indent(4, netlib.utils.hexdump(f.request.content)) -- cgit v1.2.3 From d2d3eb6490a6b342f8d205e26d04c913b8e2a5f7 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 17 Mar 2013 17:53:39 +1300 Subject: Un-break unit tests. Tsk tsk. --- libmproxy/dump.py | 1 + 1 file changed, 1 insertion(+) (limited to 'libmproxy/dump.py') diff --git a/libmproxy/dump.py b/libmproxy/dump.py index 2e0e62d9..b1022ef5 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -37,6 +37,7 @@ class Options(object): "setheaders", "server_replay", "script", + "showhost", "stickycookie", "stickyauth", "verbosity", -- cgit v1.2.3