Asynchronous Resolver Functions

async dns.asyncresolver.resolve(qname: Name | str, rdtype: RdataType | str = RdataType.A, rdclass: RdataClass | str = RdataClass.IN, tcp: bool = False, source: str | None = None, raise_on_no_answer: bool = True, source_port: int = 0, lifetime: float | None = None, search: bool | None = None, backend: Backend | None = None) Answer[source]

Query nameservers asynchronously to find the answer to the question.

This is a convenience function that uses the default resolver object to make the query.

See dns.asyncresolver.Resolver.resolve() for more information on the parameters.

async dns.asyncresolver.resolve_address(ipaddr: str, *args: Any, **kwargs: Any) Answer[source]

Use a resolver to run a reverse query for PTR records.

See dns.asyncresolver.Resolver.resolve_address() for more information on the parameters.

async dns.asyncresolver.resolve_name(name: Name | str, family: int = AddressFamily.AF_UNSPEC, **kwargs: Any) HostAnswers[source]

Use a resolver to asynchronously query for address records.

See dns.asyncresolver.Resolver.resolve_name() for more information on the parameters.

async dns.asyncresolver.canonical_name(name: Name | str) Name[source]

Determine the canonical name of name.

See dns.resolver.Resolver.canonical_name() for more information on the parameters and possible exceptions.

async dns.asyncresolver.try_ddr(timeout: float = 5.0) None[source]

Try to update the default resolver’s nameservers using Discovery of Designated Resolvers (DDR). If successful, the resolver will subsequently use DNS-over-HTTPS or DNS-over-TLS for future queries.

See dns.resolver.Resolver.try_ddr() for more information.

async dns.asyncresolver.zone_for_name(name: Name | str, rdclass: RdataClass = RdataClass.IN, tcp: bool = False, resolver: Resolver | None = None, backend: Backend | None = None) Name[source]

Find the name of the zone which contains the specified name.

See dns.resolver.Resolver.zone_for_name() for more information on the parameters and possible exceptions.

async dns.asyncresolver.make_resolver_at(where: Name | str, port: int = 53, family: int = AddressFamily.AF_UNSPEC, resolver: Resolver | None = None) Resolver[source]

Make a stub resolver using the specified destination as the full resolver.

where, a dns.name.Name or str the domain name or IP address of the full resolver.

port, an int, the port to use. If not specified, the default is 53.

family, an int, the address family to use. This parameter is used if where is not an address. The default is socket.AF_UNSPEC in which case the first address returned by resolve_name() will be used, otherwise the first address of the specified family will be used.

resolver, a dns.asyncresolver.Resolver or None, the resolver to use for resolution of hostnames. If not specified, the default resolver will be used.

Returns a dns.resolver.Resolver or raises an exception.

async dns.asyncresolver.resolve_at(where: Name | str, qname: Name | str, rdtype: RdataType | str = RdataType.A, rdclass: RdataClass | str = RdataClass.IN, tcp: bool = False, source: str | None = None, raise_on_no_answer: bool = True, source_port: int = 0, lifetime: float | None = None, search: bool | None = None, backend: Backend | None = None, port: int = 53, family: int = AddressFamily.AF_UNSPEC, resolver: Resolver | None = None) Answer[source]

Query nameservers to find the answer to the question.

This is a convenience function that calls dns.asyncresolver.make_resolver_at() to make a resolver, and then uses it to resolve the query.

See dns.asyncresolver.Resolver.resolve for more information on the resolution parameters, and dns.asyncresolver.make_resolver_at for information about the resolver parameters where, port, family, and resolver.

If making more than one query, it is more efficient to call dns.asyncresolver.make_resolver_at() and then use that resolver for the queries instead of calling resolve_at() multiple times.

dns.asyncresolver.default_resolver = None
dns.asyncresolver.get_default_resolver() Resolver[source]

Get the default asynchronous resolver, initializing it if necessary.

dns.asyncresolver.reset_default_resolver() None[source]

Re-initialize default asynchronous resolver.

Note that the resolver configuration (i.e. /etc/resolv.conf on UNIX systems) will be re-read immediately.