pydns
Simple Python DNS Library. DNS Packet-Parsing/Client/Server
Installation
pip install pydns3
Examples
Packet Parsing
from pydns import Message
raw = \
b"\x5c\x7d\x81\x80\x00\x01\x00\x00\x00\x01\x00\x01\x03\x77\x77\x77" \
b"\x06\x67\x6f\x6f\x67\x6c\x65\x03\x63\x6f\x6d\x00\x00\x06\x00\x01" \
b"\xc0\x10\x00\x06\x00\x01\x00\x00\x00\x3c\x00\x26\x03\x6e\x73\x31" \
b"\xc0\x10\x09\x64\x6e\x73\x2d\x61\x64\x6d\x69\x6e\xc0\x10\x1e\xe8" \
b"\x04\x72\x00\x00\x03\x84\x00\x00\x03\x84\x00\x00\x07\x08\x00\x00" \
b"\x00\x3c\x00\x00\x29\x04\xd0\x00\x00\x00\x00\x00\x00"
req = Message.unpack(raw)
print(req)
Client
from pydns import Question, RType
from pydns.client import UdpClient
client = UdpClient([('8.8.8.8', 53)])
query = Question(b'www.google.com', RType.AAAA)
res = client.query(query)
print(res)
Simple Server
import logging
from pyserve import listen_udp_threaded
from pydns.client import UdpClient
from pydns.server import Server
from pydns.server.backend import MemoryBackend, Forwarder, Cache
# declare and configure server address and forwarding client addresses
server_addr = ('127.0.0.1', 53)
client_addrs = [('8.8.8.8', 53)]
# prepare simple memory backend as base provider
backend = MemoryBackend()
backend.save_domain_dict(b'example.com', {
'A': [{'ip': '1.2.3.4'}],
'MX': [{'preference': 1, 'exchange': b'mx.example.com'}],
'SOA': [{
'mname': b'mname.example.com',
'rname': b'rname.example.com',
'serialver': 1,
'refresh': 2,
'retry': 3,
'expire': 4,
'minimum': 5
}]
})
# wrap memory backend w/ client forwarder
client = UdpClient(client_addrs)
backend = Forwarder(backend, client)
# wrap backend w/ cache to cache forwarded content
backend = Cache(backend)
# configure optional logger for server implementaion
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('myserver')
logger.setLevel(logging.INFO)
# launch server and run forever using pyserve
listen_udp_threaded(server_addr, Server, backend=backend, logger=logger)
Metadata
Release files for pydns3 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydns3-0.0.10.tar.gz | 23.1 kB | Without provenance | Details for pydns3-0.0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydns3-0.0.10-py3-none-any.whl | Python 3 | none | any | Details for pydns3-0.0.10-py3-none-any.whl |
Total release size: 53.6 kB
Release files / pydns3-0.0.10.tar.gz
| Download URL | pydns3-0.0.10.tar.gz |
|---|---|
| Size | 23.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c33402db6e0e6ad2076790c1aa621eb3e9dca807c6e96d7f52d5de03f2dda5a2
|
|
BLAKE2b-256 checksum How to use checksums |
842609ab28c9deb27a58f95d652bf813b29a1ff0d5da7974050a002b74e4690a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.8.20
|
Release files / pydns3-0.0.10-py3-none-any.whl
| Download URL | pydns3-0.0.10-py3-none-any.whl |
|---|---|
| Size | 30.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
63b811a301edc8f1d3ac0db95bd4140c469418e1dfd8945653c1322e8e74debf
|
|
BLAKE2b-256 checksum How to use checksums |
70d71e190bcbbfd14fe3774b184c72eaabcb6c9a2a6ae9ec94dc301b141d2acb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.8.20
|
Security for pydns3 0.0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.