net: Disallow sending messages until the version handshake is complete

This is a change in behavior, though it's much more sane now than before.
This commit is contained in:
Cory Fields
2017-01-26 12:35:49 -05:00
parent 12752af0cc
commit 7a8c251901
2 changed files with 7 additions and 3 deletions

View File

@@ -1277,7 +1277,6 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
// Change version
pfrom->SetSendVersion(nSendVersion);
pfrom->nVersion = nVersion;
pfrom->fSuccessfullyConnected = true;
if((nServices & NODE_WITNESS))
{
@@ -1387,6 +1386,7 @@ bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vR
nCMPCTBLOCKVersion = 1;
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
}
pfrom->fSuccessfullyConnected = true;
}
@@ -2725,8 +2725,8 @@ bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interruptMsg
{
const Consensus::Params& consensusParams = Params().GetConsensus();
{
// Don't send anything until we get its version message
if (pto->nVersion == 0 || pto->fDisconnect)
// Don't send anything until the version handshake is complete
if (!pto->fSuccessfullyConnected || pto->fDisconnect)
return true;
// If we get here, the outgoing message serialization version is set and can't change.