Other style fixes.

* Abstract protocol in get_peer_url.
* Replace special-purpose code with check_port.