mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge #20079: p2p: Treat handshake misbehavior like unknown message
faaad1bbacp2p: Ignore version msgs after initial version msg (MarcoFalke)fad68afcffp2p: Ignore non-version msgs before version msg (MarcoFalke) Pull request description: Handshake misbehaviour doesn't cost us more than any other unknown message, so it seems odd to treat it differently ACKs for top commit: jnewbery: utACKfaaad1bbacpracticalswift: ACKfaaad1bbac: patch looks correct Tree-SHA512: 9f30c3b5c1f6604fd02cff878f10999956152419a3dd9825f8267cbdeff7d06787418b41c7fde8a00a5e557fe89204546e05d5689042dbf7b07fbb7eb95cddff
This commit is contained in:
@@ -2255,10 +2255,8 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
|
||||
if (peer == nullptr) return;
|
||||
|
||||
if (msg_type == NetMsgType::VERSION) {
|
||||
// Each connection can only send one version message
|
||||
if (pfrom.nVersion != 0)
|
||||
{
|
||||
Misbehaving(pfrom.GetId(), 1, "redundant version message");
|
||||
if (pfrom.nVersion != 0) {
|
||||
LogPrint(BCLog::NET, "redundant version message from peer=%d\n", pfrom.GetId());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2452,7 +2450,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
|
||||
|
||||
if (pfrom.nVersion == 0) {
|
||||
// Must have a version message before anything else
|
||||
Misbehaving(pfrom.GetId(), 1, "non-version message before version handshake");
|
||||
LogPrint(BCLog::NET, "non-version message before version handshake. Message \"%s\" from peer=%d\n", SanitizeString(msg_type), pfrom.GetId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user