-from re import compile
+# Don't clobber the global compile() with a named import.
+import re
+
from typing import Optional
from djbdns.common import *
# The regex to match dnscache log lines.
-dnscache_log_re = compile(fr'({timestamp_pat}) (\w+)(.*)')
+dnscache_log_re = re.compile(fr'({timestamp_pat}) (\w+)(.*)')
def decode_client(words : list, i : int):
decode_ttl(words, 1)
if words[2] not in ("cname", "mx", "ns", "ptr", "soa"):
decode_type(words, 2)
- if words[2] == "a": # decode answer to an A query
+ if words[2] == "a":
+ # Decode the response to an 'A' query
decode_ip(words, 4)
- if words[2] == "txt": # text record
+ if words[2] == "txt":
+ # Decode the TXT record's data from hex to ASCII.
response = words[4]
if response.endswith("..."):
ellipsis = "..."