#!/usr/bin/python3
-"""
+r"""
Convert tinydns and dnscache logs to human-readable form
"""
def convert_ip(ip : str) -> str:
- """
+ r"""
Convert a hex string representing an IP address to
human-readable form.
id = int(chunks[2], 16)
words[i] += f" (id {id})"
-def decode_ip(words, i):
+def decode_ip(words : list, i : int):
r"""
Helper function to decode the ip field in a dnscache log
entry.
"""
words[i] = convert_ip(words[i])
-def decode_ttl(words, i):
+def decode_ttl(words : list, i : int):
words[i] = f"TTL={words[i]}"
-def decode_serial(words, i):
+def decode_serial(words : list, i : int):
serial = int(words[i])
words[i] = f"#{serial}"
-def decode_type(words, i):
+def decode_type(words : list, i : int):
qt = words[i]
words[i] = query_type.get(int(qt), qt)
-def handle_dnscache_log(line) -> typing.Optional[str]:
- """
+def handle_dnscache_log(line : str) -> typing.Optional[str]:
+ r"""
Handle a single log line if it matches the ``dnscache_log_re`` regex.
Parameters
def handle_tinydns_log(line : str) -> typing.Optional[str]:
- """
+ r"""
Handle a single log line if it matches the ``tinydns_log_re`` regex.
Parameters