2015-08-06 09:09:01 +00:00
|
|
|
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
|
|
|
|
2015-08-06 09:09:01 +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":
|
2015-08-08 14:08:57 +00:00
|
|
|
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
|
2015-08-08 14:08:57 +00:00
|
|
|
from .tls import TlsLayer
|