blob: 18b363d5fd75600f159427a944e8dad1dabf3c9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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_conn.address = address
# TODO: Kill event
layer = self.ctx.next_layer(self)
try:
layer()
finally:
if self.server_conn:
self._disconnect()
|