def _address_from_socket(sock):
 addr_type = sock.recv(1)
 if (addr_type == '\x01'):
  ipv4_addr = _read_exactly(sock, 4)
  return socket.inet_ntoa(ipv4_addr)
 elif (addr_type == '\x04'):
  ipv6_addr = _read_exactly(sock, 16)
  return socket.inet_ntop(socket.AF_INET6, ipv6_addr)
 elif (addr_type == '\x03'):
  addr_len = ord(sock.recv(1))
  return _read_exactly(sock, addr_len)
 else:
  raise RuntimeError(('Unexpected addr type: %r' % addr_type))

def _address_from_socket ( sock ) : addr_type = sock . recv ( 1 ) if ( addr_type == '\x01' ) : ipv4_addr = _read_exactly ( sock , 4 ) return socket . inet_ntoa ( ipv4_addr ) elif ( addr_type == '\x04' ) : ipv6_addr = _read_exactly ( sock , 16 ) return socket . inet_ntop ( socket . AF_INET6 , ipv6_addr ) elif ( addr_type == '\x03' ) : addr_len = ord ( sock . recv ( 1 ) ) return _read_exactly ( sock , addr_len ) else : raise RuntimeError ( ( 'Unexpected addr type: %r' % addr_type ) )
returns the address from the socks socket .