mitmproxy/libmproxy/protocol2/auto.py

21 lines
568 B
Python
Raw Normal View History

from __future__ import (absolute_import, print_function, division)
2015-07-25 11:31:55 +00:00
from .layer import Layer
class AutoLayer(Layer):
def __call__(self):
d = self.client_conn.rfile.peek(1)
2015-07-25 12:48:50 +00:00
if not d:
return
2015-07-25 12:48:50 +00:00
# TLS ClientHello magic, see http://www.moserware.com/2009/06/first-few-milliseconds-of-https.html#client-hello
2015-07-25 11:31:55 +00:00
if d[0] == "\x16":
layer = TlsLayer(self, True, True)
2015-07-25 11:31:55 +00:00
else:
layer = TcpLayer(self)
for m in layer():
yield m
from .rawtcp import TcpLayer
from .tls import TlsLayer