Conman Laboratories

Better living through software …

spcdns

Sean Conner

Since I had nothing better to do over Thanksgiving weekend and being curious about DNS I decided to look into it a bit. And what I found was horrible—nearly every existing DNS resolving library was horribly complex and only handled a few record types. The protocol described in RFC-1035 seemed straightforward enough (enough that made me question the complexity of existing resolving libraries) that it was only a few days work to have a nice library capable of decoding almost three dozen record types.

In fact, that you get back is a fully decoded DNS packet in a convenient in-memory representation (read: structures) that requires no futher decoding (at least, for the records I do decode) in a single call.

Okay, so the code presented here has a very stupid network interface, but my rationalization for such simplicity is, if you need to support a large number of queries then any networking interface provided will either lack a critical feature, or be difficult (to downright impossible) to integrate within an existing complex application framework. So I didn't even bother much with the networking side of things.

The API defined for this library is thread safe and makes no calls to malloc(), unlike some other DNS libraries I have checked. The code is extensively commented, so check there for more information. Also, I've included Lua bindings, just because Lua is such a cool little language.

If you use this code, or just have comments or questions, please drop me a line. Thanks.