CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-dnspython

DNS toolkit for Python supporting almost all record types with high-level and low-level DNS operations

85

1.37x
Overview
Eval results
Files

task.mdevals/scenario-1/

Multi-Transport DNS Lookup

Build a client that issues DNS queries to a single configurable nameserver using multiple transports (UDP, TCP, TLS, HTTPS), falling back from UDP to TCP when needed while keeping results consistent across protocols.

Capabilities

UDP queries

  • Resolves the A record for example.com using UDP and returns all IPv4 addresses sorted lexicographically. @test

TCP fallback on truncation

  • When a UDP response signals truncation (for example due to a low UDP payload size), the client transparently retries the same query over TCP and returns the complete IPv6 answers that were truncated over UDP. @test

TLS resolution

  • Resolves the A record for example.com using DNS-over-TLS against the configured endpoint and returns addresses including 93.184.216.34. @test

HTTPS resolution

  • Resolves the A record for example.com using DNS-over-HTTPS (GET) against the configured endpoint and returns addresses including 93.184.216.34. @test

Implementation

@generates

API

class TransportClient:
    def __init__(self, nameserver: str, udp_timeout: float = 2.0, tcp_timeout: float = 4.0, tls_port: int = 853, https_url: str | None = None):
        """Create a client bound to a target resolver supporting UDP/TCP/TLS and an optional HTTPS endpoint."""

    def query(self, qname: str, rdtype: str = "A", transport: str = "udp") -> list[str]:
        """Execute a DNS query over the chosen transport ('udp', 'tcp', 'tls', 'https') and return the RDATA text values in order of arrival."""

    def query_with_fallback(self, qname: str, rdtype: str = "A", udp_payload_size: int = 512) -> list[str]:
        """Perform a UDP query (respecting the payload size), and on truncation or timeout, retry over TCP automatically before returning results."""

Dependencies { .dependencies }

dnspython { .dependency }

Python DNS toolkit for building, sending, and parsing DNS messages across multiple transports.

Install with Tessl CLI

npx tessl i tessl/pypi-dnspython

tile.json