minor fixes

This commit is contained in:
Maximilian Hils 2015-07-25 14:48:50 +02:00
parent e815915b22
commit 531ca4a356
4 changed files with 7 additions and 8 deletions

View File

@ -3,4 +3,4 @@ from .layer import RootContext
from .socks import Socks5IncomingLayer
from .rawtcp import TcpLayer
from .auto import AutoLayer
__all__ = ["Socks5IncomingLayer", "TcpLayer", "AutoLayer", "RootContext"]
__all__ = ["Socks5IncomingLayer", "TcpLayer", "AutoLayer", "RootContext"]

View File

@ -5,6 +5,8 @@ from .layer import Layer
class AutoLayer(Layer):
def __call__(self):
d = self.client_conn.rfile.peek(1)
# TLS ClientHello magic, see http://www.moserware.com/2009/06/first-few-milliseconds-of-https.html#client-hello
if d[0] == "\x16":
layer = SslLayer(self, True, True)
else:

View File

@ -37,6 +37,7 @@ from ..proxy import ProxyError2, Log
from ..proxy.connection import ServerConnection
from .messages import Connect, Reconnect, ChangeServer
class RootContext(object):
"""
The outmost context provided to the root layer.
@ -148,4 +149,4 @@ class ServerConnectionMixin(object):
def _set_address(self, address):
a = tcp.Address.wrap(address)
self.log("Set new server address: " + repr(a), "debug")
self.server_address = address
self.server_address = address

View File

@ -2,6 +2,7 @@ from __future__ import (absolute_import, print_function, division, unicode_liter
from ..proxy import ProxyError, Socks5ProxyMode, ProxyError2
from .layer import Layer, ServerConnectionMixin
from .auto import AutoLayer
class Socks5IncomingLayer(Layer, ServerConnectionMixin):
@ -15,12 +16,7 @@ class Socks5IncomingLayer(Layer, ServerConnectionMixin):
self._set_address(address)
if address[1] == 443:
layer = AutoLayer(self)
else:
layer = AutoLayer(self)
layer = AutoLayer(self)
for message in layer():
if not self._handle_server_message(message):
yield message
from .auto import AutoLayer