Skip to main content

asyncdns - Pure Python asynchronous DNS for asyncio

https://travis-ci.org/al45tair/asyncdns.svg?branch=master https://readthedocs.org/projects/asyncdns/badge/?version=latest

What is this?

asyncdns is a pure Python asynchronous DNS resolver implementation written on top of asyncio. It doesn’t require any external libraries, and it doesn’t use threads or blocking functions.

Usage

asyncdns doesn’t have an equivalent to the widely used gethostbyname() or getaddrinfo() functions. Instead, you use it by constructing a Query object specifying the DNS query you wish to run, then pass it to a Resolver to actually perform the query.

There are a handful of built-in resolvers, but for demonstration purposes the easiest one to use is the SmartResolver, which automatically makes use of /etc/hosts, multicast DNS and regular DNS as appropriate.

For instance, do a simple lookup for an A record:

>>> import asyncdns, asyncio
>>> resolver = asyncdns.SmartResolver()
>>> loop = asyncio.get_event_loop()
>>> query = asyncdns.Query('www.example.com', asyncdns.A, asyncdns.IN)
>>> f = resolver.lookup(query)
>>> loop.run_until_complete(f)
>>> print(f.result())
;; No error (RD, RA)
; 1 answers:
www.example.com       54950   IN      A       93.184.216.34
; 0 authorities:
; 0 additional:

Note that you may or may not want to use SmartResolver in your code, depending on your requirements - it probably isn’t a good idea using multicast DNS on an untrusted network, for instance.

Metadata

Release files for asyncdns2 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncdns2 0.1.2
File Size Uploaded
asyncdns2-0.1.2.tar.gz 19.1 kB Details

Release files / asyncdns2-0.1.2.tar.gz

Download URL asyncdns2-0.1.2.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5d28dceb0eaa5eb1680996cf39208792bcd1e034eb8bf15768d4447f0c36ee11
BLAKE2b-256 checksum
How to use checksums
19aa20d44b8db9f877ed0b30044ed64543b0272d85a8e6cf26b43d2f1cb3c163
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.1.3

1 release file

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page