diff --git a/aiosocks/protocols.py b/aiosocks/protocols.py index 1c69f0b..0a43b3d 100644 --- a/aiosocks/protocols.py +++ b/aiosocks/protocols.py @@ -319,8 +319,8 @@ class Socks5Protocol(BaseSocksProtocol): ) if chosen_auth[1] == c.SOCKS5_AUTH_UNAME_PWD: - req = [0x01, len(self._auth.login).to_bytes(1, 'big'), self._auth.login, - len(self._auth.password).to_bytes(1, 'big'), self._auth.password] + req = [0x01, len(self._auth.login), self._auth.login, + len(self._auth.password), self._auth.password] self.write_request(req) auth_status = await self.read_response(2) @@ -361,7 +361,7 @@ class Socks5Protocol(BaseSocksProtocol): # it's not an IP number, so it's probably a DNS name. if self._remote_resolve: host_bytes = host.encode('idna') - req = [c.SOCKS5_ATYP_DOMAIN, len(host_bytes).to_bytes(1, 'big'), + req = [c.SOCKS5_ATYP_DOMAIN, len(host_bytes), host_bytes, port_bytes] else: family, host_bytes = await self._get_dst_addr() diff --git a/tests/test_protocols.py b/tests/test_protocols.py index 121fd9c..384b986 100644 --- a/tests/test_protocols.py +++ b/tests/test_protocols.py @@ -566,7 +566,7 @@ async def test_socks5_build_dst_addr_domain_with_remote_resolve(loop): proto = make_socks5(loop) dst_req, resolved = await proto.build_dst_address('python.org' * 20, 80) - assert dst_req == [0x03, b'\xc8', b'python.org' * 20, b'\x00P'] + assert dst_req == [0x03, 200, b'python.org' * 20, b'\x00P'] assert resolved == ('python.org' * 20, 80)