def dns_lookup(cls, host, port, afi=socket.AF_UNSPEC):
        """Returns a list of getaddrinfo structs, optionally filtered to an afi (ipv4 / ipv6)"""
        # XXX: all DNS functions in Python are blocking. If we really
        # want to be non-blocking here, we need to use a 3rd-party
        # library like python-adns, or move resolution onto its
        # own thread. This will be subject to the default libc
        # name resolution timeout (5s on most Linux boxes)
        try:
            return list(filter(cls.is_inet_4_or_6,
                               socket.getaddrinfo(host, port, afi,
                                                  socket.SOCK_STREAM)))
        except socket.gaierror as ex:
            log.warning("DNS lookup failed for proxy %s:%d, %r", host, port, ex)
            return []
Returns a list of getaddrinfo structs, optionally filtered to an afi (ipv4 / ipv6)
kafka/socks5_wrapper.py