dns: refactor code to have also a .cpp file

Lately, I'm starting to like the idea that we don't expose
on the public header the private implementation details.