def whataremyips(bind_ip=None):
 if bind_ip:
  try:
   (_, _, _, _, sockaddr) = socket.getaddrinfo(bind_ip, None, 0, socket.SOCK_STREAM, 0, socket.AI_NUMERICHOST)[0]
   if (sockaddr[0] not in ('0.0.0.0', '::')):
    return [bind_ip]
  except socket.gaierror:
   pass
 addresses = []
 for interface in netifaces.interfaces():
  try:
   iface_data = netifaces.ifaddresses(interface)
   for family in iface_data:
    if (family not in (netifaces.AF_INET, netifaces.AF_INET6)):
     continue
    for address in iface_data[family]:
     addr = address['addr']
     if (family == netifaces.AF_INET6):
      addr = expand_ipv6(addr.split('%')[0])
     addresses.append(addr)
  except ValueError:
   pass
 return addresses

def whataremyips ( bind_ip = None ) : if bind_ip : try : ( _ , _ , _ , _ , sockaddr ) = socket . getaddrinfo ( bind_ip , None , 0 , socket . SOCK_STREAM , 0 , socket . AI_NUMERICHOST ) [ 0 ] if ( sockaddr [ 0 ] not in ( '0.0.0.0' , '::' ) ) : return [ bind_ip ] except socket . gaierror : pass addresses = [ ] for interface in netifaces . interfaces ( ) : try : iface_data = netifaces . ifaddresses ( interface ) for family in iface_data : if ( family not in ( netifaces . AF_INET , netifaces . AF_INET6 ) ) : continue for address in iface_data [ family ] : addr = address [ 'addr' ] if ( family == netifaces . AF_INET6 ) : addr = expand_ipv6 ( addr . split ( '%' ) [ 0 ] ) addresses . append ( addr ) except ValueError : pass return addresses
get "our" ip addresses .