aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol/handle.py
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy/protocol/handle.py')
-rw-r--r--libmproxy/protocol/handle.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/libmproxy/protocol/handle.py b/libmproxy/protocol/handle.py
new file mode 100644
index 00000000..71c3243a
--- /dev/null
+++ b/libmproxy/protocol/handle.py
@@ -0,0 +1,21 @@
+from . import http, tcp
+
+protocols = {
+ 'http': dict(handler=http.HTTPHandler, flow=http.HTTPFlow),
+ 'tcp': dict(handler=tcp.TCPHandler)
+} # PyCharm type hinting behaves bad if this is a dict constructor...
+
+
+def _handler(conntype, connection_handler):
+ if conntype in protocols:
+ return protocols[conntype]["handler"](connection_handler)
+
+ raise NotImplementedError # pragma: nocover
+
+
+def handle_messages(conntype, connection_handler):
+ return _handler(conntype, connection_handler).handle_messages()
+
+
+def handle_error(conntype, connection_handler, error):
+ return _handler(conntype, connection_handler).handle_error(error) \ No newline at end of file