aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-02-21 11:08:35 +1300
committerAldo Cortesi <aldo@nullcube.com>2011-02-21 11:08:35 +1300
commitfe99871df873f755ef5f4770edf37304f88102d7 (patch)
tree81cac2d8573f4e48d08284baadff8e0440e58ac0 /libmproxy
parentc3e38970718aed37dd70e8aad0085957b62a09ac (diff)
downloadmitmproxy-fe99871df873f755ef5f4770edf37304f88102d7.tar.gz
mitmproxy-fe99871df873f755ef5f4770edf37304f88102d7.tar.bz2
mitmproxy-fe99871df873f755ef5f4770edf37304f88102d7.zip
Add --kill option to mitmdump
If this option is passed all requests that are not part of a replayed conversation are killed. If the option is not passed, such requests are passed through to the server as usual.
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/dump.py15
-rw-r--r--libmproxy/flow.py7
2 files changed, 16 insertions, 6 deletions
diff --git a/libmproxy/dump.py b/libmproxy/dump.py
index d43da44b..7f6f1e7c 100644
--- a/libmproxy/dump.py
+++ b/libmproxy/dump.py
@@ -6,11 +6,12 @@ class DumpError(Exception): pass
class Options(object):
__slots__ = [
- "verbosity",
- "wfile",
+ "kill",
"request_script",
"response_script",
"replay",
+ "verbosity",
+ "wfile",
]
def __init__(self, **kwargs):
for k, v in kwargs.items():
@@ -66,7 +67,15 @@ class DumpMaster(flow.FlowMaster):
f = flow.FlowMaster.handle_request(self, r)
if self.o.request_script:
self._runscript(f, self.o.request_script)
- if not self.playback(f):
+
+ if self.o.replay:
+ pb = self.playback(f)
+ if not pb:
+ if self.o.kill:
+ self.state.kill_flow(f)
+ else:
+ r.ack()
+ else:
r.ack()
def indent(self, n, t):
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index 4025a30d..996b45cd 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -44,9 +44,10 @@ class ServerPlaybackState:
chronological order.
"""
for i in flows:
- h = self._hash(i)
- l = self.fmap.setdefault(self._hash(i), [])
- l.append(i)
+ if i.response:
+ h = self._hash(i)
+ l = self.fmap.setdefault(self._hash(i), [])
+ l.append(i)
def _hash(self, flow):
"""