socks5 flake8 fixes

This commit is contained in:
lakshyacis 2019-09-10 14:55:07 +05:30
parent 79d1b1b9e2
commit 8182e159df
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -66,10 +66,9 @@ class Socks5(Proxy):
elif ret[1] == 2: elif ret[1] == 2:
# username/password # username/password
self.append_write_buf( self.append_write_buf(
struct.pack('BB', 1, len(self._auth[0])) + struct.pack(
self._auth[0] + struct.pack('B', len(self._auth[1])) + 'BB', 1, len(self._auth[0])) + self._auth[0] + struct.pack(
self._auth[1] 'B', len(self._auth[1])) + self._auth[1])
)
self.set_state("auth_needed", length=2, expectBytes=2) self.set_state("auth_needed", length=2, expectBytes=2)
else: else:
if ret[1] == 0xff: if ret[1] == 0xff:
@ -178,11 +177,8 @@ class Socks5Connection(Socks5):
if Proxy._remote_dns: # pylint: disable=protected-access if Proxy._remote_dns: # pylint: disable=protected-access
# Resolve remotely # Resolve remotely
self.ipaddr = None self.ipaddr = None
self.append_write_buf( self.append_write_buf(chr(0x03).encode() + chr(
chr(0x03).encode() + len(self.destination[0])).encode() + self.destination[0])
chr(len(self.destination[0])).encode() +
self.destination[0]
)
else: else:
# Resolve locally # Resolve locally
self.ipaddr = socket.inet_aton( self.ipaddr = socket.inet_aton(
@ -212,10 +208,8 @@ class Socks5Resolver(Socks5):
"""Perform resolving""" """Perform resolving"""
# Now we can request the actual connection # Now we can request the actual connection
self.append_write_buf(struct.pack('BBB', 0x05, 0xF0, 0x00)) self.append_write_buf(struct.pack('BBB', 0x05, 0xF0, 0x00))
self.append_write_buf( self.append_write_buf(chr(0x03).encode() + chr(
chr(0x03).encode() + chr(len(self.host)).encode() + len(self.host)).encode() + str(self.host))
str(self.host)
)
self.append_write_buf(struct.pack(">H", self.port)) self.append_write_buf(struct.pack(">H", self.port))
self.set_state("pre_connect", length=0, expectBytes=4) self.set_state("pre_connect", length=0, expectBytes=4)
return True return True