From 5a0b74213921fa92d91ed3c94af6241215656680 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 28 Feb 2024 14:13:44 -0500 Subject: [PATCH] fix: add handshake check to unsigned messages as well --- service/default/p2p.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/service/default/p2p.go b/service/default/p2p.go index c6562d2..8ba15ba 100644 --- a/service/default/p2p.go +++ b/service/default/p2p.go @@ -434,6 +434,11 @@ func (p *P2PServiceDefault) OnNewPeerListen(peer net.Peer, verifyId bool) { return fmt.Errorf("unknown message type: %d", reader.Kind) } + if handler.RequiresHandshake() && !peer.IsHandshakeDone() { + p.Logger().Debug("Peer is not handshake done, ignoring message", zap.Any("type", types.ProtocolMethodMap[types.ProtocolMethod(reader.Kind)])) + return nil + } + data := protocol.IncomingMessageData{ Original: message, Data: reader.Data,