Refactor network_util; use it in DHT.

* Use tornado.netutil to check for valid IPs.
* Abstract protocol in get_peer_url.
* Prefer importing modules than names.
* Other style fixes.
Refactor code in connection.py.

* Drop unused peer_alive attribute.
* Drop unused responses_received attribute.
* Make failure cases stand out in PeerConnection.send_raw.
* Make failure cases stand out in CryptoPeerConnection.start_handshake.
* Straighten CryptoPeerConnection.encrypt.
* Refactor CryptoPeerConnection.send.
  * Make failure cases stand out.
  * Guard against encrypt returning False.
* Drop PeerListener.stop.
  * Do not destroy global context arbitrarily.
  * Turn TransportLayer.shutdown into abstract method.
* Straighten PeerListener.listen.
* Remove unused import.