From aef3b626a70de5f385c8f5496c2e49575b5c3e1c Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 11 Aug 2015 20:27:34 +0200 Subject: wip commit --- libmproxy/protocol2/socks_proxy.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 libmproxy/protocol2/socks_proxy.py (limited to 'libmproxy/protocol2/socks_proxy.py') diff --git a/libmproxy/protocol2/socks_proxy.py b/libmproxy/protocol2/socks_proxy.py new file mode 100644 index 00000000..c89477ca --- /dev/null +++ b/libmproxy/protocol2/socks_proxy.py @@ -0,0 +1,22 @@ +from __future__ import (absolute_import, print_function, division) + +from ..exceptions import ProtocolException +from ..proxy import ProxyError, Socks5ProxyMode +from .layer import Layer, ServerConnectionMixin + + +class Socks5Proxy(Layer, ServerConnectionMixin): + def __call__(self): + try: + s5mode = Socks5ProxyMode(self.config.ssl_ports) + address = s5mode.get_upstream_server(self.client_conn)[2:] + except ProxyError as e: + # TODO: Unmonkeypatch + raise ProtocolException(str(e), e) + + self.server_address = address + + layer = self.ctx.next_layer(self) + for message in layer(): + if not self._handle_server_message(message): + yield message -- cgit v1.2.3