Browse Source

as write_request handles bytes, just use this instead of to_bytes...

main
John-Mark Gurney 5 years ago
parent
commit
4964c1903e
2 changed files with 4 additions and 4 deletions
  1. +3
    -3
      aiosocks/protocols.py
  2. +1
    -1
      tests/test_protocols.py

+ 3
- 3
aiosocks/protocols.py View File

@@ -319,8 +319,8 @@ class Socks5Protocol(BaseSocksProtocol):
) )


if chosen_auth[1] == c.SOCKS5_AUTH_UNAME_PWD: 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) self.write_request(req)


auth_status = await self.read_response(2) 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. # it's not an IP number, so it's probably a DNS name.
if self._remote_resolve: if self._remote_resolve:
host_bytes = host.encode('idna') 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] host_bytes, port_bytes]
else: else:
family, host_bytes = await self._get_dst_addr() family, host_bytes = await self._get_dst_addr()


+ 1
- 1
tests/test_protocols.py View File

@@ -566,7 +566,7 @@ async def test_socks5_build_dst_addr_domain_with_remote_resolve(loop):
proto = make_socks5(loop) proto = make_socks5(loop)
dst_req, resolved = await proto.build_dst_address('python.org' * 20, 80) 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) assert resolved == ('python.org' * 20, 80)






Loading…
Cancel
Save