Improve protocol-level handshaking protocol:

This commit restructures the HTTP based protocol negotiation that `rippled`
executes and introduces support for negotiation of compression for peer
links which, if implemented, should result in significant bandwidth savings
for some server roles.

This commit also introduces the new `[network_id]` configuration option
that administrators can use to specify which network the server is part of
and intends to join. This makes it possible for servers from different
networks to drop the link early.

The changeset also improves the log messages generated when negotiation
of a peer link upgrade fails. In the past, no useful information would
be logged, making it more difficult for admins to troubleshoot errors.

This commit also fixes RIPD-237 and RIPD-451
This commit is contained in:
Nik Bougalis
2019-06-22 17:02:13 -07:00
parent 3ea525430e
commit f6916bfd42
41 changed files with 1496 additions and 1581 deletions

View File

@@ -25,8 +25,6 @@
namespace ripple {
/** Describes a Ripple/RTXP protocol version. */
using ProtocolVersion = std::pair<std::uint16_t, std::uint16_t>;
/** Versioning information for this build. */
// VFALCO The namespace is deprecated
@@ -46,25 +44,8 @@ getVersionString();
std::string const&
getFullVersionString();
/** Construct a protocol version from a packed 32-bit protocol identifier */
ProtocolVersion
make_protocol (std::uint32_t version);
/** The protocol version we speak and prefer. */
ProtocolVersion const&
getCurrentProtocol();
/** The oldest protocol version we will accept. */
ProtocolVersion const& getMinimumProtocol ();
} // BuildInfo (DEPRECATED)
std::string
to_string (ProtocolVersion const& p);
std::uint32_t
to_packed (ProtocolVersion const& p);
} // ripple
#endif

View File

@@ -0,0 +1,69 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2015 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_PROTOCOL_KEYTYPE_H_INCLUDED
#define RIPPLE_PROTOCOL_KEYTYPE_H_INCLUDED
#include <string>
#include <boost/optional.hpp>
namespace ripple {
enum class KeyType
{
secp256k1 = 0,
ed25519 = 1,
};
inline
boost::optional<KeyType>
keyTypeFromString (std::string const& s)
{
if (s == "secp256k1")
return KeyType::secp256k1;
if (s == "ed25519")
return KeyType::ed25519;
return {};
}
inline
char const*
to_string (KeyType type)
{
if (type == KeyType::secp256k1)
return "secp256k1";
if (type == KeyType::ed25519)
return "ed25519";
return "INVALID";
}
template <class Stream>
inline
Stream& operator<<(Stream& s, KeyType type)
{
return s << to_string(type);
}
}
#endif

View File

@@ -21,7 +21,7 @@
#define RIPPLE_PROTOCOL_PUBLICKEY_H_INCLUDED
#include <ripple/basics/Slice.h>
#include <ripple/crypto/KeyType.h> // move to protocol/
#include <ripple/protocol/KeyType.h>
#include <ripple/protocol/STExchange.h>
#include <ripple/protocol/tokens.h>
#include <ripple/protocol/UintTypes.h>

View File

@@ -22,7 +22,7 @@
#include <ripple/basics/Buffer.h>
#include <ripple/basics/Slice.h>
#include <ripple/crypto/KeyType.h> // move to protocol/
#include <ripple/protocol/KeyType.h>
#include <ripple/protocol/PublicKey.h>
#include <ripple/protocol/Seed.h>
#include <ripple/protocol/tokens.h>

View File

@@ -33,7 +33,7 @@ namespace BuildInfo {
char const* const versionString = "1.4.0"
#if defined(DEBUG) || defined(SANITIZER)
"+"
"+"
#ifdef DEBUG
"DEBUG"
#ifdef SANITIZER
@@ -49,46 +49,9 @@ char const* const versionString = "1.4.0"
//--------------------------------------------------------------------------
;
ProtocolVersion const&
getCurrentProtocol ()
{
static ProtocolVersion currentProtocol (
//--------------------------------------------------------------------------
//
// The protocol version we speak and prefer (edit this if necessary)
//
1, // major
2 // minor
//
//--------------------------------------------------------------------------
);
return currentProtocol;
}
ProtocolVersion const&
getMinimumProtocol ()
{
static ProtocolVersion minimumProtocol (
//--------------------------------------------------------------------------
//
// The oldest protocol version we will accept. (edit this if necessary)
//
1, // major
2 // minor
//
//--------------------------------------------------------------------------
);
return minimumProtocol;
}
//
//
// Don't touch anything below this line
//
//------------------------------------------------------------------------------
std::string const&
getVersionString ()
@@ -110,26 +73,6 @@ std::string const& getFullVersionString ()
return value;
}
ProtocolVersion
make_protocol (std::uint32_t version)
{
return ProtocolVersion(
static_cast<std::uint16_t> ((version >> 16) & 0xffff),
static_cast<std::uint16_t> (version & 0xffff));
}
}
std::string
to_string (ProtocolVersion const& p)
{
return std::to_string (p.first) + "." + std::to_string (p.second);
}
std::uint32_t
to_packed (ProtocolVersion const& p)
{
return (static_cast<std::uint32_t> (p.first) << 16) + p.second;
}
} // BuildInfo
} // ripple