[log] log too much peers (#3936)

* [log] log too much peers
* fix go import
Signed-off-by: Leo Chen <leo@harmony.one>
Co-authored-by: Nita Neou <soph@harmony.one>
pull/3948/head
Leo Chen 3 years ago committed by GitHub
parent d5a89692a6
commit 80b8333469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      p2p/security/security.go

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/harmony-one/harmony/internal/utils"
libp2p_network "github.com/libp2p/go-libp2p-core/network" libp2p_network "github.com/libp2p/go-libp2p-core/network"
ma "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -54,6 +55,8 @@ func (m *Manager) OnConnectCheck(net libp2p_network.Network, conn libp2p_network
} }
if len(peers) > m.maxConnPerIP { if len(peers) > m.maxConnPerIP {
utils.Logger().Warn().Int("len(peers)", len(peers)).Int("maxConnPerIP", m.maxConnPerIP).
Msg("Too much peers, closing")
return net.ClosePeer(conn.RemotePeer()) return net.ClosePeer(conn.RemotePeer())
} }

Loading…
Cancel
Save