Split peer connect logic to another class (RIPD-711):

All of the logic for establishing an outbound peer connection including
the initial HTTP handshake exchange is moved into a separate class. This
allows PeerImp to have a strong invariant: All PeerImp objects that exist
represent active peer connections that have already gone through the
handshake process.
This commit is contained in:
Vinnie Falco
2014-11-22 07:36:50 -08:00
committed by Nik Bougalis
parent 930a0beaf1
commit 32062e439f
14 changed files with 963 additions and 378 deletions

View File

@@ -207,6 +207,22 @@ parseHello (beast::http::message const& m, beast::Journal journal)
// protocol version in TMHello is obsolete,
// it is supplanted by the values in the headers.
{
// Required
auto const iter = h.find ("Upgrade");
if (iter == h.end())
return result;
auto const versions = parse_ProtocolVersions(iter->second);
if (versions.empty())
return result;
hello.set_protoversion(
(static_cast<std::uint32_t>(versions.back().first) << 16) |
(static_cast<std::uint32_t>(versions.back().second)));
hello.set_protoversionmin(
(static_cast<std::uint32_t>(versions.front().first) << 16) |
(static_cast<std::uint32_t>(versions.front().second)));
}
{
// Required
auto const iter = h.find ("Public-Key");