diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-08-30 20:15:19 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-08-30 20:15:19 +0200 |
commit | 1f47f7b6b29cd1229264edf75194652824d94705 (patch) | |
tree | 4b52337daddbc97aa40b80ea84e795cf7448be9b /libmproxy/protocol/handle.py | |
parent | 82730c1c6ff4a1e593de48309d02de2b49cade5d (diff) | |
download | mitmproxy-1f47f7b6b29cd1229264edf75194652824d94705.tar.gz mitmproxy-1f47f7b6b29cd1229264edf75194652824d94705.tar.bz2 mitmproxy-1f47f7b6b29cd1229264edf75194652824d94705.zip |
refactor protocol handling, fix #332
Diffstat (limited to 'libmproxy/protocol/handle.py')
-rw-r--r-- | libmproxy/protocol/handle.py | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/libmproxy/protocol/handle.py b/libmproxy/protocol/handle.py index a238b349..100c7368 100644 --- a/libmproxy/protocol/handle.py +++ b/libmproxy/protocol/handle.py @@ -6,21 +6,12 @@ protocols = { 'tcp': dict(handler=tcp.TCPHandler) } - -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) - - -def handle_server_reconnect(conntype, connection_handler, state): - return _handler(conntype, connection_handler).handle_server_reconnect(state)
\ No newline at end of file +def protocol_handler(protocol): + """ + @type protocol: str + @returns: libmproxy.protocol.primitives.ProtocolHandler + """ + if protocol in protocols: + return protocols[protocol]["handler"] + + raise NotImplementedError("Unknown Protocol: %s" % protocol) # pragma: nocover
\ No newline at end of file |