From effb545d20747ff1139f5295140c3cad48fe84cd Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Tue, 19 Jan 2021 17:20:25 +0200 Subject: [PATCH] Fix wrong condition and add logs (#1435) --- app/protocol/flows/handshake/handshake.go | 2 +- app/protocol/protocol.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/protocol/flows/handshake/handshake.go b/app/protocol/flows/handshake/handshake.go index ff2ce6d3b..aa6c5f686 100644 --- a/app/protocol/flows/handshake/handshake.go +++ b/app/protocol/flows/handshake/handshake.go @@ -82,7 +82,7 @@ func HandleHandshake(context HandleHandshakeContext, netConnection *netadapter.N err := context.AddToPeers(peer) if err != nil { - if errors.As(err, &common.ErrPeerWithSameIDExists) { + if errors.Is(err, common.ErrPeerWithSameIDExists) { return nil, protocolerrors.Wrap(false, err, "peer already exists") } return nil, err diff --git a/app/protocol/protocol.go b/app/protocol/protocol.go index 6ce09a3d7..89601a087 100644 --- a/app/protocol/protocol.go +++ b/app/protocol/protocol.go @@ -44,6 +44,7 @@ func (m *Manager) routerInitializer(router *routerpkg.Router, netConnection *net panic(err) } if isBanned { + log.Infof("Peer %s is banned. Disconnecting...", netConnection) netConnection.Disconnect() return } @@ -87,6 +88,7 @@ func (m *Manager) handleError(err error, netConnection *netadapter.NetConnection panic(err) } } + log.Debugf("Disconnecting from %s (reason: %s)", netConnection, protocolErr.Cause) netConnection.Disconnect() return }