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:
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());
|
||||
|
||||
Reference in New Issue
Block a user