]> gitweb.michael.orlitzky.com - djbdns-logparse.git/blobdiff - bin/djbdns-logparse.py
bin/djbdns-logparse.py: improve existing decode_* docs.
[djbdns-logparse.git] / bin / djbdns-logparse.py
index c6b98722c6899ca0bbdf4fcbdaf86c9289492dfc..0abd5bc168b9370e4198311bf14b683f9162f01c 100755 (executable)
@@ -125,6 +125,9 @@ def decode_client(words : list, i : int):
       1. clientip:clientport, used by tcpopen/tcpclose entries,
       2. clientip:clientport:id, used by "query" entries.
 
+    We convert each part from hex to decimal, and in the second
+    format, separate the packet id from the client information.
+
     Parameters
     ----------
 
@@ -172,7 +175,7 @@ def decode_ip(words : list, i : int):
     entry.
 
     A single "serverip" field is present in the lame, nodata,
-    nxdomain, and rr entry types.
+    nxdomain, and rr entry types. We convert it from hex to decimal.
 
     Parameters
     ----------
@@ -202,11 +205,43 @@ def decode_ip(words : list, i : int):
         >>> decode_ip(words, 1)
         >>> words
         ['foo', '0000:0000:0000:0000:0000:ffff:7f00:0001', 'bar', 'quux']
-
     """
     words[i] = convert_ip(words[i])
 
 def decode_ttl(words : list, i : int):
+    r"""
+    Helper function to decode the ttl field in a dnscache log
+    entry.
+
+    A single "ttl" field is present in the nodata, nxdomain, and
+    rr entry types. We prefix it with "TTL=" so that its meaning
+    is clear in the human-readable logs.
+
+    Parameters
+    ----------
+
+    words : list
+        The ``words`` list (a list of fields) from
+        :func:`handle_dnscache_log`.
+
+    i : int
+        The index of the ttl field within ``words``
+
+    Returns
+    -------
+
+    Nothing; the ``i``th entry in the ``words`` list is modified
+    in-place.
+
+    Examples
+    --------
+
+        >>> words = ["c0a80101", "20865", "1", "www.example.com.", "5db8d822"]
+        >>> decode_ttl(words, 1)
+        >>> words
+        ['c0a80101', 'TTL=20865', '1', 'www.example.com.', '5db8d822']
+
+    """
     words[i] = f"TTL={words[i]}"
 
 def decode_serial(words : list, i : int):