DNS toolkit for Python supporting almost all record types with high-level and low-level DNS operations
85
A lightweight async DNS helper that issues concurrent lookups while allowing callers to choose the event-loop backend (asyncio or trio).
ValueError. @testexample.com against 1.1.1.1 returns at least one IPv4 address string via the configured backend. @testexample.com, and an "AAAA" list that may be empty but is always present. @test@generates
from typing import Iterable, Literal, Sequence
BackendName = Literal["asyncio", "trio"]
class AsyncDnsClient:
def __init__(self, nameservers: Sequence[str] | None = None, backend: BackendName = "asyncio", timeout: float | None = 2.0):
"""Configure the resolver with optional nameservers, backend, and timeout seconds."""
def set_backend(self, backend: BackendName) -> None:
"""Switch the active async backend; raise ValueError for unsupported names."""
async def lookup(self, name: str, record_type: str = "A", *, nameservers: Iterable[str] | None = None) -> list[str]:
"""Resolve a single record type asynchronously using the active backend; optional nameserver override."""
async def lookup_dual_stack(self, name: str) -> dict[str, list[str]]:
"""Resolve both A and AAAA concurrently using the active backend; returns {"A": [...], "AAAA": [...]} with lists possibly empty."""Provides asynchronous DNS querying and resolver abstractions with backend selection.
Install with Tessl CLI
npx tessl i tessl/pypi-dnspythondocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10