ethereum/cpp-ethereum — pull request #24 by danielhams (2014-02-05 09:53:14+00:00)
Title: Fixes to peer address and port handling.

Fixes for:

* Zero addresses and ports in alephzero
* Replication of a peer to another node with a zero peer port

Updated the PeerSession to accept the address and optional port on construction.

* For outgoing connections the port is already known and passed in
the constructor.
* For incoming connections the port defaults to 0 and we wait
for the hello over the wire to extract the listen port

Questionable choice:

This patch includes logic that will disconnect an incoming connection if the connectee supplies zero as the port in the "Hello" part of the connection message (working on the theory that they can't participate in P2P).

It's possible this could be changed, but will require some other modifications to maintain the peer outside of the peers list replicated to other nodes in the network.

Let me know if you'd prefer a different approach / some of my assumptions are off.