aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/dump.py
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy/dump.py')
-rw-r--r--libmproxy/dump.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/libmproxy/dump.py b/libmproxy/dump.py
index e30c2422..ece6e190 100644
--- a/libmproxy/dump.py
+++ b/libmproxy/dump.py
@@ -1,5 +1,5 @@
import sys, os
-import flow
+import flow, filt
class DumpError(Exception): pass
@@ -18,11 +18,16 @@ class Options(object):
class DumpMaster(flow.FlowMaster):
- def __init__(self, server, options, outfile=sys.stdout):
+ def __init__(self, server, options, filtstr, outfile=sys.stdout):
flow.FlowMaster.__init__(self, server, flow.State())
self.outfile = outfile
self.o = options
+ if filtstr:
+ self.filt = filt.parse(filtstr)
+ else:
+ self.filt = None
+
if options.wfile:
path = os.path.expanduser(options.wfile)
try:
@@ -46,6 +51,9 @@ class DumpMaster(flow.FlowMaster):
def handle_response(self, msg):
f = flow.FlowMaster.handle_response(self, msg)
if f:
+ msg.ack()
+ if self.filt and not f.match(self.filt):
+ return
if 0 < self.o.verbosity < 3:
print >> self.outfile, ">>",
print >> self.outfile, msg.request.short()
@@ -66,10 +74,7 @@ class DumpMaster(flow.FlowMaster):
for i in msg.assemble().splitlines():
print >> self.outfile, "\t", i
print >> self.outfile, "<<"
-
- msg.ack()
self.state.delete_flow(f)
-
if self.o.wfile:
self.fwriter.add(f)