make bittorrent-dht extendible.

the end goal of this patchset is this:
https://github.com/xaiki/dht-exp/blob/master/dht.js

basically, be able to implement other extensions, and use your awesome code for moar things.

first patch is needed to make tests pass,
second patch adds ipv6 support, for free.

then we put together and export easy helper functions.
b9f62ee is not actually needed, but I think it's nice.

cheers.
I changed this to avoid using try-catch which has poor performance characteristics (can't be optimized by V8).