Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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]