Michael Orlitzky [Thu, 22 Sep 2022 01:25:59 +0000 (21:25 -0400)]
djbdns/common.py: assume IPv6 if an address isn't IPv4.
In other words, probably crash if convert_ip() is fed garbage. That's
OK. We could check the length of the hex string and raise a ValueError
if it isn't 8 or 32, but we might be solving problems that don't exist.
Michael Orlitzky [Tue, 20 Sep 2022 23:48:10 +0000 (19:48 -0400)]
djbdns/io.py: handle BrokenPipeError in parse_logfile().
This avoids a (harmless) crash when the output of djbdns-logparse is
piped to a process (such as head/tail) that closes the pipe before
djbdns-logparse is done writing to it.
Michael Orlitzky [Tue, 20 Sep 2022 23:21:28 +0000 (19:21 -0400)]
bin/djbdns-logparse: handle SIGINT (again).
I removed the KeyboardInterrupt handler from the original program and
have now put it back as an async handler for SIGINT. This is helpful
when the user accidentally starts the program with no arguments and it
just sits there until he hits Ctrl-C (which would previously have
shown a stack trace).
Michael Orlitzky [Fri, 16 Sep 2022 23:16:57 +0000 (19:16 -0400)]
*/*: refactor into a driver program and a library.
Now there are a few separate modules in a "djbdns" package, and the
djbdns-logparse executable that makes use of them contains only what
the main() function used to.
Instead of using True/False to signal success after possibly using
print() to actually write the result, we not just return either the
processed string, or None.
Michael Orlitzky [Thu, 15 Sep 2022 22:50:26 +0000 (18:50 -0400)]
bin/djbdns-logparse.py: move regex handling down a level.
It was a bit awkward to match a line against a regex, and then to have
to immediately pass that match object into a function that knows what
to do with it (to avoid duplicating work). Now the handle_tinydns_log()
and handle_dnscache_log() functions create the match object themselves,
and signal success or failure by returning a boolean.
Michael Orlitzky [Thu, 15 Sep 2022 02:53:37 +0000 (22:53 -0400)]
bin/djbdns-logparse.py: add some newer type mappings.
I've added srv, naptr, dnskey, tlsa, https, and caa type mappings
based on what my own logs contain. Only SRV is actually supported by
tinydns. There are probably others in use today that will show up
eventually.