aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmproxy/protocol2/__init__.py2
-rw-r--r--libmproxy/protocol2/auto.py2
-rw-r--r--libmproxy/protocol2/layer.py3
-rw-r--r--libmproxy/protocol2/socks.py8
4 files changed, 7 insertions, 8 deletions
diff --git a/libmproxy/protocol2/__init__.py b/libmproxy/protocol2/__init__.py
index 6f4bfe44..20e5a888 100644
--- a/libmproxy/protocol2/__init__.py
+++ b/libmproxy/protocol2/__init__.py
@@ -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"] \ No newline at end of file
+__all__ = ["Socks5IncomingLayer", "TcpLayer", "AutoLayer", "RootContext"]
diff --git a/libmproxy/protocol2/auto.py b/libmproxy/protocol2/auto.py
index 1c4293ac..a00f1f52 100644
--- a/libmproxy/protocol2/auto.py
+++ b/libmproxy/protocol2/auto.py
@@ -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:
diff --git a/libmproxy/protocol2/layer.py b/libmproxy/protocol2/layer.py
index 14263f64..1cc8df70 100644
--- a/libmproxy/protocol2/layer.py
+++ b/libmproxy/protocol2/layer.py
@@ -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 \ No newline at end of file
+ self.server_address = address
diff --git a/libmproxy/protocol2/socks.py b/libmproxy/protocol2/socks.py
index 9ca30bb4..7835b1a4 100644
--- a/libmproxy/protocol2/socks.py
+++ b/libmproxy/protocol2/socks.py
@@ -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