def decode_request(orig_offset, data):
 offset = orig_offset
 if ((len(data) - offset) < 4):
  return (orig_offset, None)
 (version, cmd, rsv, address_type) = struct.unpack_from('!BBBB', data, offset)
 offset += 4
 assert (version == SOCKS_VERSION), (version, SOCKS_VERSION)
 assert (rsv == 0)
 (offset, destination_address) = __decode_address(address_type, offset, data)
 if (not destination_address):
  return (orig_offset, None)
 if ((len(data) - offset) < 2):
  return (orig_offset, None)
 (destination_port,) = struct.unpack_from('!H', data, offset)
 offset += 2
 return (offset, Request(version, cmd, rsv, address_type, destination_address, destination_port))

def decode_request ( orig_offset , data ) : offset = orig_offset if ( ( len ( data ) - offset ) < 4 ) : return ( orig_offset , None ) ( version , cmd , rsv , address_type ) = struct . unpack_from ( '!BBBB' , data , offset ) offset += 4 assert ( version == SOCKS_VERSION ) , ( version , SOCKS_VERSION ) assert ( rsv == 0 ) ( offset , destination_address ) = __decode_address ( address_type , offset , data ) if ( not destination_address ) : return ( orig_offset , None ) if ( ( len ( data ) - offset ) < 2 ) : return ( orig_offset , None ) ( destination_port , ) = struct . unpack_from ( '!H' , data , offset ) offset += 2 return ( offset , Request ( version , cmd , rsv , address_type , destination_address , destination_port ) )
try to decode a socks5 request .