or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/dnslib@0.9.x
tile.json

tessl/pypi-dnslib

tessl install tessl/pypi-dnslib@0.9.0

Simple library to encode/decode DNS wire-format packets

Agent Success

Agent success rate when using this tile

97%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.76x

Baseline

Agent success rate without this tile

55%

task.mdevals/scenario-5/

DNS Query Tool

Build a command-line DNS query tool that can query different DNS record types from specified nameservers.

Requirements

Your tool should accept the following command-line arguments:

  1. Domain name (required): The domain to query (e.g., example.com)
  2. Record type (optional, default: A): The DNS record type to query (e.g., A, AAAA, MX, TXT, NS, CNAME)
  3. Nameserver (optional, default: 8.8.8.8): The DNS server to query
  4. Protocol (optional, default: UDP): Transport protocol to use (UDP or TCP)

The tool should:

  • Send a DNS query to the specified nameserver
  • Display the query result including:
    • Response status
    • Answer section with all returned records
  • Handle errors gracefully (timeouts, invalid responses, network errors)
  • Support both UDP and TCP protocols
  • Return appropriate exit codes (0 for success, non-zero for errors)

Output Format

The output should be human-readable and include at least:

  • The question that was asked (domain and record type)
  • The answer records received
  • Response flags (e.g., authoritative answer, truncated, etc.)

Dependencies { .dependencies }

dnslib { .dependency }

Provides DNS protocol support for encoding/decoding DNS packets and sending queries.

Implementation Files

Implement your solution in dns_query.py with a main function that can be executed from the command line.

Test Cases

Create tests in test_dns_query.py:

Test Case 1: Basic A Record Query @test

Query google.com for A records using the default nameserver (8.8.8.8). The query should succeed and return at least one IPv4 address.

Test Case 2: MX Record Query @test

Query gmail.com for MX records. The query should succeed and return mail exchange records with priority values.

Test Case 3: TCP Query @test

Query example.com for A records using TCP protocol. The query should succeed using TCP transport.

Test Case 4: Multiple Answer Records @test

Query google.com for TXT records. The query should handle and display multiple TXT records if present.