The dns.asyncresolver.Resolver Class¶
The async resolver is a subclass of dns.resolver.Resolver
and has the
same attributes. The methods are similar, but I/O methods like resolve()
are asynchronous.
- class dns.asyncresolver.Resolver(filename: str = '/etc/resolv.conf', configure: bool = True)[source]¶
Asynchronous DNS stub resolver.
filename, a
str
or file object, specifying a file in standard /etc/resolv.conf format. This parameter is meaningful only when configure is true and the platform is POSIX.configure, a
bool
. If True (the default), the resolver instance is configured in the normal fashion for the operating system the resolver is running on. (I.e. by reading a /etc/resolv.conf file on POSIX systems and from the registry on Windows systems.)- async canonical_name(name: Union[dns.name.Name, str]) dns.name.Name [source]¶
Determine the canonical name of name.
The canonical name is the name the resolver uses for queries after all CNAME and DNAME renamings have been applied.
name, a
dns.name.Name
orstr
, the query name.This method can raise any exception that
resolve()
can raise, other thandns.resolver.NoAnswer
anddns.resolver.NXDOMAIN
.Returns a
dns.name.Name
.
- async resolve(qname: Union[dns.name.Name, str], rdtype: Union[dns.rdatatype.RdataType, str] = RdataType.A, rdclass: Union[dns.rdataclass.RdataClass, str] = RdataClass.IN, tcp: bool = False, source: Optional[str] = None, raise_on_no_answer: bool = True, source_port: int = 0, lifetime: Optional[float] = None, search: Optional[bool] = None, backend: Optional[dns._asyncbackend.Backend] = None) dns.resolver.Answer [source]¶
Query nameservers asynchronously to find the answer to the question.
backend, a
dns.asyncbackend.Backend
, orNone
. IfNone
, the default, then dnspython will use the default backend.See
dns.resolver.Resolver.resolve()
for the documentation of the other parameters, exceptions, and return type of this method.
- async resolve_address(ipaddr: str, *args: Any, **kwargs: Any) dns.resolver.Answer [source]¶
Use an asynchronous resolver to run a reverse query for PTR records.
This utilizes the resolve() method to perform a PTR lookup on the specified IP address.
ipaddr, a
str
, the IPv4 or IPv6 address you want to get the PTR record for.All other arguments that can be passed to the resolve() function except for rdtype and rdclass are also supported by this function.