mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Track server and protocol versions and minimum supported versions. This is a
protocol-breaking change. It's needed because other protocol-breaking changes are needed for security reasons, and we don't want subtly-incompatible nodes connecting.
This commit is contained in:
@@ -112,8 +112,6 @@ void Config::setup(const std::string& strConf)
|
||||
// Defaults
|
||||
//
|
||||
|
||||
VERSION = 1;
|
||||
|
||||
NETWORK_START_TIME = 1319844908;
|
||||
|
||||
PEER_PORT = SYSTEM_PEER_PORT;
|
||||
|
||||
@@ -43,10 +43,6 @@ const int SYSTEM_WEBSOCKET_PORT = 6562;
|
||||
class Config
|
||||
{
|
||||
public:
|
||||
// Core software parameters
|
||||
int VERSION;
|
||||
std::string VERSION_STR;
|
||||
|
||||
// Configuration parameters
|
||||
boost::filesystem::path CONFIG_FILE;
|
||||
boost::filesystem::path CONFIG_DIR;
|
||||
|
||||
34
src/Peer.cpp
34
src/Peer.cpp
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "../json/writer.h"
|
||||
|
||||
#include "Version.h"
|
||||
#include "Peer.h"
|
||||
#include "Config.h"
|
||||
#include "Application.h"
|
||||
@@ -565,15 +566,20 @@ void Peer::processReadBuffer()
|
||||
|
||||
void Peer::recvHello(newcoin::TMHello& packet)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Log(lsINFO) << "Recv(Hello) v=" << packet.version() << ", index=" << packet.ledgerindex();
|
||||
#endif
|
||||
Log(lsTRACE) << "Recv(Hello) v=" << packet.versionmajor() << "." << packet.versionminor();
|
||||
bool bDetach = true;
|
||||
|
||||
// Cancel verification timeout.
|
||||
(void) mVerifyTimer.cancel();
|
||||
|
||||
if (!mNodePublic.setNodePublic(packet.nodepublic()))
|
||||
if ((packet.minprotoversionmajor() > PROTO_VERSION_MAJ) ||
|
||||
((packet.minprotoversionmajor() == PROTO_VERSION_MAJ) && (packet.minprotoversionminor() > PROTO_VERSION_MIN)))
|
||||
{
|
||||
Log(lsINFO) << "Recv(Hello): Server requires protocol version " <<
|
||||
packet.minprotoversionmajor() << "." << packet.minprotoversionminor() << " we run " <<
|
||||
PROTO_VERSION_MAJ << "." << PROTO_VERSION_MIN;
|
||||
}
|
||||
else if (!mNodePublic.setNodePublic(packet.nodepublic()))
|
||||
{
|
||||
Log(lsINFO) << "Recv(Hello): Disconnect: Bad node public key.";
|
||||
}
|
||||
@@ -585,6 +591,14 @@ void Peer::recvHello(newcoin::TMHello& packet)
|
||||
{ // Successful connection.
|
||||
Log(lsINFO) << "Recv(Hello): Connect: " << mNodePublic.humanNodePublic();
|
||||
|
||||
if ( (packet.versionmajor() != SERVER_VERSION_MAJ) || (packet.versionminor() != SERVER_VERSION_MIN))
|
||||
{
|
||||
if (packet.has_fullversion())
|
||||
Log(lsINFO) << " Peer is running version " << packet.fullversion();
|
||||
else
|
||||
Log(lsINFO) << " Peer is running version " << packet.versionmajor() << "." << packet.versionminor();
|
||||
}
|
||||
|
||||
if (mClientConnect)
|
||||
{
|
||||
// If we connected due to scan, no longer need to scan.
|
||||
@@ -1104,16 +1118,20 @@ void Peer::sendHello()
|
||||
|
||||
newcoin::TMHello h;
|
||||
|
||||
h.set_version(theConfig.VERSION);
|
||||
h.set_ledgerindex(theApp->getOPs().getCurrentLedgerID());
|
||||
h.set_versionmajor(SERVER_VERSION_MAJ);
|
||||
h.set_versionminor(SERVER_VERSION_MIN);
|
||||
h.set_protoversionmajor(PROTO_VERSION_MAJ);
|
||||
h.set_protoversionminor(PROTO_VERSION_MIN);
|
||||
h.set_minprotoversionminor(MIN_PROTO_MAJ);
|
||||
h.set_minprotoversionmajor(MIN_PROTO_MIN);
|
||||
h.set_fullversion(SERVER_VERSION);
|
||||
h.set_nettime(theApp->getOPs().getNetworkTimeNC());
|
||||
h.set_nodepublic(theApp->getWallet().getNodePublic().humanNodePublic());
|
||||
h.set_nodeproof(&vchSig[0], vchSig.size());
|
||||
h.set_ipv4port(theConfig.PEER_PORT);
|
||||
|
||||
Ledger::pointer closedLedger = theApp->getMasterLedger().getClosedLedger();
|
||||
assert(closedLedger && closedLedger->isClosed());
|
||||
if (closedLedger->isClosed())
|
||||
if (closedLedger && closedLedger->isClosed())
|
||||
{
|
||||
uint256 hash = closedLedger->getHash();
|
||||
h.set_closedledger(hash.begin(), hash.GetSerializeSize());
|
||||
|
||||
@@ -37,14 +37,20 @@ enum MessageType {
|
||||
|
||||
|
||||
message TMHello {
|
||||
required uint32 version = 1;
|
||||
optional uint32 ledgerIndex = 2;
|
||||
optional uint64 netTime = 3;
|
||||
optional bytes nodePublic = 4; // node may opt to remain anonymous
|
||||
optional bytes nodeProof = 5;
|
||||
optional uint32 ipv4Port = 6;
|
||||
optional bytes closedLedger = 7; // our last closed ledger
|
||||
optional bytes previousLedger = 8; // the ledger before the last closed ledger
|
||||
required uint32 versionMinor = 1;
|
||||
required uint32 versionMajor = 2;
|
||||
required uint32 protoVersionMinor = 3;
|
||||
required uint32 protoVersionMajor = 4;
|
||||
required uint32 minProtoVersionMinor = 5;
|
||||
required uint32 minProtoVersionMajor = 6;
|
||||
required bytes nodePublic = 7;
|
||||
required bytes nodeProof = 8;
|
||||
optional string fullVersion = 9;
|
||||
optional uint64 netTime = 10;
|
||||
optional uint32 ipv4Port = 11;
|
||||
optional uint32 ledgerIndex = 12;
|
||||
optional bytes closedLedger = 13; // our last closed ledger
|
||||
optional bytes previousLedger = 14; // the ledger before the last closed ledger
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,14 +15,11 @@
|
||||
#include "BitcoinUtil.h"
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
#include "Version.h"
|
||||
|
||||
using namespace boost;
|
||||
using namespace boost::asio;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Json::Value JSONRPCError(int code, const std::string& message)
|
||||
{
|
||||
Json::Value error(Json::objectValue);
|
||||
@@ -116,7 +113,7 @@ std::string HTTPReply(int nStatus, const std::string& strMsg)
|
||||
rfc1123Time().c_str(),
|
||||
access.c_str(),
|
||||
strMsg.size(),
|
||||
theConfig.VERSION_STR.c_str(),
|
||||
SERVER_VERSION,
|
||||
strMsg.c_str());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user