mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Merge pull request #1619 from mhils/fix-socks-tls
Fix SOCKS5 mode with TLS
This commit is contained in:
commit
7047531a3c
@ -53,9 +53,7 @@ class Socks5Proxy(protocol.Layer, protocol.ServerConnectionMixin):
|
|||||||
except (socks.SocksError, netlib.exceptions.TcpException) as e:
|
except (socks.SocksError, netlib.exceptions.TcpException) as e:
|
||||||
raise exceptions.Socks5ProtocolException("SOCKS5 mode failure: %s" % repr(e))
|
raise exceptions.Socks5ProtocolException("SOCKS5 mode failure: %s" % repr(e))
|
||||||
|
|
||||||
# https://github.com/mitmproxy/mitmproxy/issues/839
|
self.server_conn.address = connect_request.addr
|
||||||
address_bytes = (connect_request.addr.host.encode("idna"), connect_request.addr.port)
|
|
||||||
self.server_conn.address = tcp.Address(address_bytes, connect_request.addr.use_ipv6)
|
|
||||||
|
|
||||||
layer = self.ctx.next_layer(self)
|
layer = self.ctx.next_layer(self)
|
||||||
try:
|
try:
|
||||||
|
@ -536,6 +536,18 @@ class TestSocks5(tservers.SocksModeTest):
|
|||||||
assert b"SOCKS5 mode failure" in f.content
|
assert b"SOCKS5 mode failure" in f.content
|
||||||
|
|
||||||
|
|
||||||
|
class TestSocks5SSL(tservers.SocksModeTest):
|
||||||
|
ssl = True
|
||||||
|
|
||||||
|
def test_simple(self):
|
||||||
|
p = self.pathoc_raw()
|
||||||
|
with p.connect():
|
||||||
|
p.socks_connect(("localhost", self.server.port))
|
||||||
|
p.convert_to_ssl()
|
||||||
|
f = p.request("get:/p/200")
|
||||||
|
assert f.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
class TestHttps2Http(tservers.ReverseProxyTest):
|
class TestHttps2Http(tservers.ReverseProxyTest):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user