How to use the pycares.reverse_address function in pycares

To help you get started, we’ve selected a few pycares examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saghul / uvent / uvent / resolver.py View on Github external
def gethostbyaddr(self, ip_address):
        waiter = Waiter(self.hub)
        cb = partial(self._ares_cb2, waiter)
        try:
            self._channel.gethostbyaddr(ip_address, cb)
        except ValueError:
            result = self.getaddrinfo(ip_address, None, family=socket.AF_UNSPEC, socktype=socket.SOCK_DGRAM)
            ip_address = result[0][-1][0]
            self._channel.gethostbyaddr(ip_address, cb)
        result = waiter.get()
        aliases = result.aliases if result.name == 'localhost' else [pycares.reverse_address(ip_address)]
        return (result.name, aliases, result.addresses)
github nnewsom / webbies / lib / DNSResolver.py View on Github external
def query_ip(self,ip):
        if ip not in self.rlookup_history:
            try:
                hostnames = yield from self.resolver.query(pycares.reverse_address(ip),"PTR")
            except aiodns.error.DNSError:
                hostnames = []
            self.rlookup_history[ip] = hostnames
        return self.rlookup_history[ip]