aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mitmproxy/controller.py23
-rw-r--r--test/mitmproxy/test_controller.py4
2 files changed, 25 insertions, 2 deletions
diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py
index cc7e2e76..5a354fd2 100644
--- a/mitmproxy/controller.py
+++ b/mitmproxy/controller.py
@@ -6,6 +6,27 @@ import sys
from . import exceptions
+Events = frozenset([
+ "clientconnect",
+ "clientdisconnect",
+ "serverconnect",
+ "serverdisconnect",
+
+ "tcp_open",
+ "tcp_message",
+ "tcp_error",
+ "tcp_close",
+
+ "request",
+ "response",
+ "responseheaders",
+
+ "next_layer",
+
+ "error",
+ "log",
+])
+
class ControlError(Exception):
pass
@@ -43,6 +64,8 @@ class Master(object):
# exception is thrown.
while True:
mtype, obj = self.event_queue.get(timeout=timeout)
+ if mtype not in Events:
+ raise ControlError("Unknown event %s"%repr(mtype))
handle_func = getattr(self, "handle_" + mtype)
if not handle_func.func_dict.get("handler"):
raise ControlError(
diff --git a/test/mitmproxy/test_controller.py b/test/mitmproxy/test_controller.py
index fbbebaa6..4b8656da 100644
--- a/test/mitmproxy/test_controller.py
+++ b/test/mitmproxy/test_controller.py
@@ -18,7 +18,7 @@ class TestMaster(object):
def test_simple(self):
class DummyMaster(controller.Master):
@controller.handler
- def handle_panic(self, _):
+ def handle_log(self, _):
m.should_exit.set()
def tick(self, timeout):
@@ -29,7 +29,7 @@ class TestMaster(object):
assert not m.should_exit.is_set()
msg = TMsg()
msg.reply = controller.DummyReply()
- m.event_queue.put(("panic", msg))
+ m.event_queue.put(("log", msg))
m.run()
assert m.should_exit.is_set()