aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol/handle.py
blob: 49cb3c1b0c06705e8da3598a9c37206cb33a49ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from __future__ import absolute_import
from . import http, tcp

protocols = {
    'http': dict(handler=http.HTTPHandler, flow=http.HTTPFlow),
    'tcp': dict(handler=tcp.TCPHandler)
}


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