mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 18:42:19 +00:00
abfa374165
* separated convertions into utils.go * added log to bad peers * more verbose errors and names * warn when banning bad peer * has and get in function name * space * lint * ops * little rename * deleted unused func * revert
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package sentinel
|
|
|
|
import (
|
|
"github.com/libp2p/go-libp2p/core/control"
|
|
"github.com/libp2p/go-libp2p/core/network"
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
"github.com/multiformats/go-multiaddr"
|
|
)
|
|
|
|
// InterceptPeerDial tests whether we're permitted to Dial the specified peer.
|
|
func (_ *Sentinel) InterceptPeerDial(_ peer.ID) (allow bool) {
|
|
return true
|
|
}
|
|
|
|
// InterceptAddrDial tests whether we're permitted to dial the specified
|
|
// multiaddr for the given peer.
|
|
func (s *Sentinel) InterceptAddrDial(pid peer.ID, m multiaddr.Multiaddr) (allow bool) {
|
|
return !s.peers.IsBadPeer(pid)
|
|
}
|
|
|
|
// InterceptAccept checks whether the incidental inbound connection is allowed.
|
|
func (s *Sentinel) InterceptAccept(n network.ConnMultiaddrs) (allow bool) {
|
|
return !s.HasTooManyPeers()
|
|
}
|
|
|
|
// InterceptSecured tests whether a given connection, now authenticated,
|
|
// is allowed.
|
|
func (_ *Sentinel) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) (allow bool) {
|
|
return true
|
|
}
|
|
|
|
// InterceptUpgraded tests whether a fully capable connection is allowed.
|
|
func (_ *Sentinel) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason) {
|
|
return true, 0
|
|
}
|