From fad68afcff731153d1c83f7f56c91ecbb264b59a Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 4 Oct 2020 17:34:26 +0200 Subject: p2p: Ignore non-version msgs before version msg Sending a non-version message before the initial version message is peer misbehavior. Though, it seems arbitrary and confusing to disconnect only after exactly 100 non-version messages. So remove the Misbehaving and instead rely on the existing disconnect-due-to-handshake-timeout logic. --- src/net_processing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/net_processing.cpp b/src/net_processing.cpp index c649cf7757..df97d0e2e7 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2477,7 +2477,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; } -- cgit v1.2.3 From faaad1bbac46cfeb22654b4c59f0aac7a680c03a Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 5 Oct 2020 16:21:59 +0200 Subject: p2p: Ignore version msgs after initial version msg Sending a version message after the intial version message is peer misbehavior. Though, it seems arbitrary and confusing to disconnect only after exactly 100 version messages. Duplicate version messages affect us no different than any other unknown message. So remove the Misbehaving and ignore the redundant msgs. --- src/net_processing.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/net_processing.cpp b/src/net_processing.cpp index df97d0e2e7..f21fb8a49b 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2286,10 +2286,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; } -- cgit v1.2.3