Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/socks5.py
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | def handle(self): | ||||
ulen = recvall(self.conn, 1)[0] | ulen = recvall(self.conn, 1)[0] | ||||
username = str(recvall(self.conn, ulen)) | username = str(recvall(self.conn, ulen)) | ||||
plen = recvall(self.conn, 1)[0] | plen = recvall(self.conn, 1)[0] | ||||
password = str(recvall(self.conn, plen)) | password = str(recvall(self.conn, plen)) | ||||
# Send authentication response | # Send authentication response | ||||
self.conn.sendall(bytearray([0x01, 0x00])) | self.conn.sendall(bytearray([0x01, 0x00])) | ||||
# Read connect request | # Read connect request | ||||
(ver, cmd, rsv, atyp) = recvall(self.conn, 4) | ver, cmd, _, atyp = recvall(self.conn, 4) | ||||
if ver != 0x05: | if ver != 0x05: | ||||
raise IOError( | raise IOError( | ||||
'Invalid socks version %i in connect request' % ver) | 'Invalid socks version %i in connect request' % ver) | ||||
if cmd != Command.CONNECT: | if cmd != Command.CONNECT: | ||||
raise IOError('Unhandled command %i in connect request' % cmd) | raise IOError('Unhandled command %i in connect request' % cmd) | ||||
if atyp == AddressType.IPV4: | if atyp == AddressType.IPV4: | ||||
addr = recvall(self.conn, 4) | addr = recvall(self.conn, 4) | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |