aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mitmproxy/console/flowlist.py2
-rw-r--r--mitmproxy/console/flowview.py2
-rw-r--r--mitmproxy/controller.py3
-rw-r--r--mitmproxy/flow/master.py6
-rw-r--r--mitmproxy/flow/state.py10
-rw-r--r--mitmproxy/models/flow.py8
-rw-r--r--mitmproxy/web/app.py2
-rw-r--r--test/mitmproxy/test_flow.py8
8 files changed, 23 insertions, 18 deletions
diff --git a/mitmproxy/console/flowlist.py b/mitmproxy/console/flowlist.py
index 653dfa02..ba555647 100644
--- a/mitmproxy/console/flowlist.py
+++ b/mitmproxy/console/flowlist.py
@@ -158,7 +158,7 @@ class ConnectionItem(urwid.WidgetWrap):
(maxcol,) = xxx_todo_changeme
key = common.shortcuts(key)
if key == "a":
- self.flow.accept_intercept(self.master)
+ self.flow.resume(self.master)
signals.flowlist_change.send(self)
elif key == "d":
if self.flow.killable:
diff --git a/mitmproxy/console/flowview.py b/mitmproxy/console/flowview.py
index 0422e72b..b8f91bdb 100644
--- a/mitmproxy/console/flowview.py
+++ b/mitmproxy/console/flowview.py
@@ -519,7 +519,7 @@ class FlowView(tabs.Tabs):
# Pass scroll events to the wrapped widget
self._w.keypress(size, key)
elif key == "a":
- self.flow.accept_intercept(self.master)
+ self.flow.resume(self.master)
signals.flow_change.send(self, flow = self.flow)
elif key == "A":
self.master.accept_all()
diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py
index 148fda77..a225634a 100644
--- a/mitmproxy/controller.py
+++ b/mitmproxy/controller.py
@@ -27,6 +27,9 @@ Events = frozenset([
"responseheaders",
"error",
+ "intercept",
+ "resume",
+
"websocket_handshake",
"next_layer",
diff --git a/mitmproxy/flow/master.py b/mitmproxy/flow/master.py
index 3d57c7bd..85048b8c 100644
--- a/mitmproxy/flow/master.py
+++ b/mitmproxy/flow/master.py
@@ -231,12 +231,6 @@ class FlowMaster(controller.Master):
def websocket_handshake(self, f):
pass
- def handle_intercept(self, f):
- self.state.update_flow(f)
-
- def handle_accept_intercept(self, f):
- self.state.update_flow(f)
-
@controller.handler
def tcp_start(self, flow):
# TODO: This would break mitmproxy currently.
diff --git a/mitmproxy/flow/state.py b/mitmproxy/flow/state.py
index 8c8e75c7..dddb5ca5 100644
--- a/mitmproxy/flow/state.py
+++ b/mitmproxy/flow/state.py
@@ -167,7 +167,7 @@ class FlowStore(FlowList):
# TODO: Should accept_all operate on views or on all flows?
def accept_all(self, master):
for f in self._list:
- f.accept_intercept(master)
+ f.resume(master)
def kill_all(self, master):
for f in self._list:
@@ -270,6 +270,14 @@ class State:
self.add_flow(f2)
return f2
+ # Event handlers
+ def intercept(self, f):
+ self.update_flow(f)
+
+ def resume(self, f):
+ self.update_flow(f)
+
+
class DummyState:
flows = ()
diff --git a/mitmproxy/models/flow.py b/mitmproxy/models/flow.py
index 6d3fa0d5..2596165b 100644
--- a/mitmproxy/models/flow.py
+++ b/mitmproxy/models/flow.py
@@ -170,16 +170,16 @@ class Flow(stateobject.StateObject):
def intercept(self, master):
"""
- Intercept this Flow. Processing will stop until accept_intercept is
+ Intercept this Flow. Processing will stop until resume is
called.
"""
if self.intercepted:
return
self.intercepted = True
self.reply.take()
- master.handle_intercept(self)
+ master.addons("intercept", self)
- def accept_intercept(self, master):
+ def resume(self, master):
"""
Continue with the flow - called after an intercept().
"""
@@ -188,4 +188,4 @@ class Flow(stateobject.StateObject):
self.intercepted = False
self.reply.ack()
self.reply.commit()
- master.handle_accept_intercept(self)
+ master.addons("intercept", self)
diff --git a/mitmproxy/web/app.py b/mitmproxy/web/app.py
index 46bdd9e3..a81d04be 100644
--- a/mitmproxy/web/app.py
+++ b/mitmproxy/web/app.py
@@ -224,7 +224,7 @@ class AcceptFlows(RequestHandler):
class AcceptFlow(RequestHandler):
def post(self, flow_id):
- self.flow.accept_intercept(self.master)
+ self.flow.resume(self.master)
class FlowHandler(RequestHandler):
diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py
index 90b9b61d..02996881 100644
--- a/test/mitmproxy/test_flow.py
+++ b/test/mitmproxy/test_flow.py
@@ -121,7 +121,6 @@ class TestHTTPFlow:
f = tutils.tflow()
f.reply.handle()
f.intercept(fm)
- assert fm.handle_intercept.called
assert f.killable
f.kill(fm)
assert not f.killable
@@ -129,8 +128,9 @@ class TestHTTPFlow:
assert f.reply.value == Kill
def test_killall(self):
+ srv = DummyServer(None)
s = flow.State()
- fm = flow.FlowMaster(None, None, s)
+ fm = flow.FlowMaster(None, srv, s)
f = tutils.tflow()
f.reply.handle()
@@ -140,12 +140,12 @@ class TestHTTPFlow:
for i in s.view:
assert "killed" in str(i.error)
- def test_accept_intercept(self):
+ def test_resume(self):
f = tutils.tflow()
f.reply.handle()
f.intercept(mock.Mock())
assert f.reply.state == "taken"
- f.accept_intercept(mock.Mock())
+ f.resume(mock.Mock())
assert f.reply.state == "committed"
def test_replace_unicode(self):