tessl install tessl/pypi-dnslib@0.9.0Simple 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%
Build a Python utility that parses DNS zone file entries and creates DNS resource records.
Your program should read DNS zone file format text and create DNS resource records. Implement these capabilities:
Zone file format entries follow this pattern:
<name> <ttl> <class> <type> <rdata>Example inputs:
example.com. 3600 IN A 192.0.2.1
www.example.com. 3600 IN CNAME example.com.
mail.example.com. 3600 IN MX 10 mailserver.example.com.
example.com. 3600 IN AAAA 2001:db8::1For each zone file entry, your program should:
@generates
def parse_zone_record(zone_line: str):
"""
Parse a DNS zone file format line and return a DNS resource record.
Args:
zone_line: A string containing a single zone file record entry
Returns:
A DNS resource record object
Raises:
ValueError: If the zone line format is invalid
"""
pass
def record_to_zone_format(record) -> str:
"""
Convert a DNS resource record to zone file format string.
Args:
record: A DNS resource record object
Returns:
String representation in zone file format
"""
pass
def record_to_wire_format(record) -> bytes:
"""
Convert a DNS resource record to DNS wire format bytes.
Args:
record: A DNS resource record object
Returns:
Bytes in DNS wire format
"""
pass
def verify_round_trip(zone_line: str) -> bool:
"""
Verify that a zone file line can be parsed, packed, and unparsed correctly.
Args:
zone_line: A string containing a single zone file record entry
Returns:
True if round-trip conversion preserves the record data
"""
passProvides DNS packet encoding/decoding and resource record support.