Refactored all server functionality into the dns package

The main() function is now a stub calling into the library.