Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backoff peers that fail hello protocol #2695

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions protocol/hello/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
host "github.com/libp2p/go-libp2p-host"
net "github.com/libp2p/go-libp2p-net"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-swarm"
ma "github.com/multiformats/go-multiaddr"

cbu "github.com/filecoin-project/go-filecoin/cborutil"
Expand Down Expand Up @@ -90,11 +91,17 @@ func (h *Handler) handleNewStream(s net.Stream) {

switch err := h.processHelloMessage(from, &hello); err {
case ErrBadGenesis:
log.Warningf("genesis cid: %s does not match: %s, disconnecting from peer: %s", &hello.GenesisHash, h.genesis, from)
log.Warningf("genesis cid: %s does not match: %s, disconnecting from peer: %s backing off", &hello.GenesisHash, h.genesis, from)
if swrm, ok := h.host.Network().(*swarm.Swarm); ok {
swrm.Backoff().AddBackoff(from)
}
s.Conn().Close() // nolint: errcheck
return
case ErrWrongVersion:
log.Warningf("code not at same version: peer has version %s, daemon has version %s, disconnecting from peer: %s", hello.CommitSha, h.commitSha, from)
log.Warningf("code not at same version: peer has version %s, daemon has version %s, disconnecting from peer: %s backing off", hello.CommitSha, h.commitSha, from)
if swrm, ok := h.host.Network().(*swarm.Swarm); ok {
swrm.Backoff().AddBackoff(from)
}
s.Conn().Close() // nolint: errcheck
return
case nil: // ok, noop
Expand Down