Skip to main content

Python asynchronous DNS client and server library.

Project description

https://github.com/abdullahselek/async-dnspy/workflows/Python%20package/badge.svg https://codecov.io/gh/abdullahselek/async-dnspy/branch/master/graph/badge.svg https://img.shields.io/pypi/v/asyncdnspy.svg https://img.shields.io/pypi/pyversions/asyncdnspy.svg https://readthedocs.org/projects/async-dnspy/badge/?version=latest

Introduction

Python asynchronous DNS client and server library. With async-dnspy clients you can make asynchronous DNS requests to any DNS server with raw DNS data. This gives you a chance to create your low level DNS query. You can even create invalid DNS query and test your DNS servers. Most important feature of async-dnspy is to make load testing on servers.

On the first release of async-dnspy TCP and UDP clients are available that connects, send and received response of raw DNS queries. There is already a decoder class that decodes raw data and creates you readable high level DNS message. It works on Python 3.5 or newer.

Online documentation is available on https://async-dnspy.readthedocs.io/.

With in next release TCP and UDP servers will be implemented.

Installation

From PyPI

$ pip install asyncdnspy

From source

Download the latest asyncdnspy library from: https://github.com/abdullahselek/async-dnspy

Extract the source distribution and run:

$ python setup.py build
$ python setup.py install

Running Tests

The test suite can be run against a single Python version which requires pip install pytest and optionally pip install pytest-cov (these are included if you have installed dependencies from requirements.testing.txt)

To run the unit tests with a single Python version:

$ py.test tests -s -v

to also run code coverage:

$ py.test tests -s -v --cov-report html --cov=asyncdnspy

Getting the code

The code is hosted at Github.

Check out the latest development version anonymously with:

$ git clone https://github.com/abdullahselek/async-dnspy.git
$ cd async-dnspy

Sample usage

I try to document as much as I can and unit tests have all the usages. Below you can find a single sample to get an idea how to TCP client to make a DNS A record query.

tcp_client = TCPClient('8.8.8.8', 53)
tcp_client.connect()
dns_raw_message = DNSRawMessage()
data = dns_raw_message.query('google.com', RecordType.a, SocketType.tcp)
_ = tcp_client.send(data)
response = tcp_client.receive()
dns_message = DNSMessageDecoder.decode(data, response, RecordType.a, SocketType.tcp)
ipv4_address = dns_message.answers[0].get_ipv4_address()

Contributing

Contributions of any kind (bug fixes, new features…) are welcome! Please do open pull request with a clear description and adding unit tests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for asyncdnspy, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size asyncdnspy-0.1.1-py3-none-any.whl (14.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page