]> gitweb.michael.orlitzky.com - djbdns-logparse.git/commitdiff
djbdns/dnscache.py: de-indent a block that doesn't need to be guarded.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 22 Sep 2022 11:58:12 +0000 (07:58 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 22 Sep 2022 11:58:12 +0000 (07:58 -0400)
djbdns/dnscache.py

index fcd0a0d050c5f8fb8d04ca85d83a12a7324cb650..3dd6d5f4ac6282bd6aff3aa6610d4a84ef797715 100644 (file)
@@ -292,23 +292,24 @@ def handle_dnscache_log(line : str) -> Optional[str]:
         decode_ttl(words, 1)
         if words[2] not in ("cname", "mx", "ns", "ptr", "soa"):
             decode_type(words, 2)
-            if words[2] == "a":
-                # Decode the response to an 'A' query
-                decode_ip(words, 4)
-            if words[2] == "txt":
-                # Decode the TXT record's data from hex to ASCII.
-                response = words[4]
-                if response.endswith("..."):
-                    ellipsis = "..."
-                    response = response[0:-3]
-                else:
-                    ellipsis = ""
-                length = int(response[0:2], 16)
-                chars = []
-                for i in range(1, len(response)//2):
-                    chars.append(chr(int(response[2*i : (2*i)+2], 16)))
-                txt = "".join(chars)
-                words[4] = f"{length}:\"{txt}{ellipsis}\""
+
+        if words[2] == "a":
+            # Decode the response to an 'A' query
+            decode_ip(words, 4)
+        if words[2] == "txt":
+            # Decode the TXT record's data from hex to ASCII.
+            response = words[4]
+            if response.endswith("..."):
+                ellipsis = "..."
+                response = response[0:-3]
+            else:
+                ellipsis = ""
+            length = int(response[0:2], 16)
+            chars = []
+            for i in range(1, len(response)//2):
+                chars.append(chr(int(response[2*i : (2*i)+2], 16)))
+            txt = "".join(chars)
+            words[4] = f"{length}:\"{txt}{ellipsis}\""
 
     elif event == "sent":
         decode_serial(words, 0)