Pierre Habouzit: POSIX DNS APIs considered harmful.
I'm quite upset with the POSIX APIs. I'm trying to write some kind of simple piece of software, to be included in a mail chain, doing a lot of DNS queries, mostly to RBLs.
I've met two kind of problems:
- the POSIX API is synchronous, and absolutely no usual API for non blocking requests exists, there is of course:
- adns, but it's very bloated, does not work with ipv6,
- c-ares, but it's quite bloated, does not work with ipv6, and need select (cannot be used with epoll e.g.),
- libdnsresolv (hahahaha, that's an horrible patch over the BSD resolving API, it's horrible, yuck),
- udns, that's the best of the four, but still, the code do not feels very well, solid (do not check recvfrom/sendto errors e.g.).
- there is no way to escape the system resolver, which is good for usual applications, but very bad when it come to RBLs.
- only A and maybe one day AAAA queries ;
- a query will never be greater than 512 octets, so only UDP is needed ;
- you only have to ask the NS that serve your RBL (and here we use the local resolver API, to benefit from the caches), and query that RBL, no recursion is needed.



