X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=djbdns%2Ftinydns.py;fp=djbdns%2Ftinydns.py;h=d647156f7b03bec45ac23a5605dc868e31d4d942;hb=f8971980184acdac6243e806e635b420ccef1d3f;hp=34cedef376c9829d2c668e2cb8c807cbe279301e;hpb=d73740c3a7d3696aaf7f3d677f83654cbd4b3583;p=djbdns-logparse.git diff --git a/djbdns/tinydns.py b/djbdns/tinydns.py index 34cedef..d647156 100644 --- a/djbdns/tinydns.py +++ b/djbdns/tinydns.py @@ -65,33 +65,34 @@ def handle_tinydns_log(line : str) -> Optional[str]: if not match: return None - (timestamp, ip, port, id, code, type, name) = match.groups() + (timestamp, ip, port, request_id, code, query_type, name) = match.groups() ip = convert_ip(ip) port = int(port, 16) - id = int(id, 16) + request_id = int(request_id, 16) # Convert the "type" field to a human-readable record type name # using the query_type dictionary. If the right name isn't present # in the dictionary, we use the (decimal) type id instead. - type = int(type, 16) # "001c" -> 28 - type = query_type.get(type, type) # 28 -> "aaaa" + query_type = int(query_type, 16) # "001c" -> 28 + query_type = query_type_name.get(query_type, type) # 28 -> "aaaa" line_tpl = "{timestamp} " reason = query_drop_reason[code] if code == "+": - line_tpl += "sent response to {ip}:{port} (id {id}): {type} {name}" + line_tpl += "sent response to {ip}:{port} (id {request_id}): " + line_tpl += "{query_type} {name}" else: line_tpl += "dropped query ({reason}) from {ip}:{port}" if code != "/": # If the query can actually be parsed, the log line is a # bit more informative than it would have been otherwise. - line_tpl += " (id {id}): {type} {name}" + line_tpl += " (id {request_id}): {query_type} {name}" return line_tpl.format(timestamp=timestamp, reason=reason, ip=ip, port=port, - id=id, - type=type, + request_id=request_id, + query_type=query_type, name=name)