public static PeerEndpoint ReadPeerEndpoint(this NetBuffer reader) { var hasInternalAddress = reader.ReadBoolean(); PeerEndpoint endpoint; if (hasInternalAddress) { endpoint = new PeerEndpoint(reader.ReadIpv4Endpoint(), reader.ReadIpv4Endpoint()); } else { endpoint = new PeerEndpoint(reader.ReadIpv4Endpoint()); } return(endpoint); }