diffsum: display msgid for queries

Knowing the specific message ID can be useful for debugging purposes.
The displayed value is the actually message ID contained in the query,
not the respdiff's internal query ID (QID) used for identification in
LMDB.
parent f2eaf2a7
Pipeline #76907 passed with stage
in 1 minute and 27 seconds
......@@ -13,7 +13,7 @@ from respdiff.database import LMDB
from respdiff.dataformat import DiffReport, Summary
from respdiff.dnsviz import DnsvizGrok
from respdiff.query import (
convert_queries, get_printable_queries_format, get_query_iterator)
convert_queries, get_printable_queries_format, get_query_iterator, qwire_to_msgid_qname_qtype)
def parse_args() -> argparse.Namespace:
......@@ -120,7 +120,8 @@ def main():
for field in field_weights:
if field in report.summary.field_labels:
for mismatch, qids in report.summary.get_field_mismatches(field):
queries = convert_queries(get_query_iterator(lmdb, qids))
queries = convert_queries(get_query_iterator(lmdb, qids),
qwire_to_msgid_qname_qtype)
cli.print_mismatch_queries(
field,
mismatch,
......
......@@ -44,6 +44,20 @@ def qwire_to_qname_qtype(qwire: WireFormat) -> str:
dns.rdatatype.to_text(qmsg.question[0].rdtype))
def qwire_to_msgid_qname_qtype(qwire: WireFormat) -> str:
"""Get text representation of DNS wire format query"""
try:
qmsg = dns.message.from_wire(qwire)
except dns.exception.DNSException as exc:
raise ValueError('unable to parse qname from wire format') from exc
if not qmsg.question:
raise ValueError('no qname in wire format')
return '[{:05d}] {} {}'.format(
qmsg.id,
qmsg.question[0].name,
dns.rdatatype.to_text(qmsg.question[0].rdtype))
def convert_queries(
query_iterator: Iterator[Tuple[QID, WireFormat]],
qwire_to_text_func: Callable[[WireFormat], str] = qwire_to_qname_qtype
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment