Try to get peer hostname from SocketAddress

Java 7 added a new method to InetSocketAddress called getHostString()
which returns the unresolved host for a given address. This should be
suitable for use with SNI as long as it isn't an IP address.

This also helps with testing because we can use serialization tricks to
rewrite the "hostname" field of an already-serialized loopback address.

(cherry picked from commit bc8a290f2a0a0e16f078d7c9cf2b2d97edf4d0f2)

Bug: 27271561
Change-Id: I9845e57d505712cdfee87d18246a1a3b021deea3
4 files changed