Documentation ¶
Index ¶
- type ConnectionGater
- func (c *ConnectionGater) InterceptAccept(n network.ConnMultiaddrs) (allow bool)
- func (c *ConnectionGater) InterceptAddrDial(pid peer.ID, m multiaddr.Multiaddr) (allow bool)
- func (c *ConnectionGater) InterceptPeerDial(_ peer.ID) (allow bool)
- func (c *ConnectionGater) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) (allow bool)
- func (c *ConnectionGater) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason)
- func (c *ConnectionGater) NotifyDisconnect(addr multiaddr.Multiaddr)
- type PeerConnectionStrategy
- type PeerData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionGater ¶ added in v0.7.0
func NewConnectionGater ¶ added in v0.7.0
func NewConnectionGater(logger *zap.Logger) *ConnectionGater
func (*ConnectionGater) InterceptAccept ¶ added in v0.7.0
func (c *ConnectionGater) InterceptAccept(n network.ConnMultiaddrs) (allow bool)
InterceptAccept is called as soon as a transport listener receives an inbound connection request, before any upgrade takes place. Transports who accept already secure and/or multiplexed connections (e.g. possibly QUIC) MUST call this method regardless, for correctness/consistency.
func (*ConnectionGater) InterceptAddrDial ¶ added in v0.7.0
func (c *ConnectionGater) InterceptAddrDial(pid peer.ID, m multiaddr.Multiaddr) (allow bool)
InterceptAddrDial is called on an imminent outbound dial to a peer on a particular address. Blocking connections at this stage is typical for address filtering.
func (*ConnectionGater) InterceptPeerDial ¶ added in v0.7.0
func (c *ConnectionGater) InterceptPeerDial(_ peer.ID) (allow bool)
InterceptPeerDial is called on an imminent outbound peer dial request, prior to the addresses of that peer being available/resolved. Blocking connections at this stage is typical for blacklisting scenarios.
func (*ConnectionGater) InterceptSecured ¶ added in v0.7.0
func (c *ConnectionGater) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) (allow bool)
InterceptSecured is called for both inbound and outbound connections, after a security handshake has taken place and we've authenticated the peer
func (*ConnectionGater) InterceptUpgraded ¶ added in v0.7.0
func (c *ConnectionGater) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason)
InterceptUpgraded is called for inbound and outbound connections, after libp2p has finished upgrading the connection entirely to a secure, multiplexed channel.
func (*ConnectionGater) NotifyDisconnect ¶ added in v0.7.0
func (c *ConnectionGater) NotifyDisconnect(addr multiaddr.Multiaddr)
type PeerConnectionStrategy ¶ added in v0.4.0
PeerConnectionStrategy is a utility to connect to peers, but only if we have not recently tried connecting to them already
func NewPeerConnectionStrategy ¶ added in v0.4.0
func NewPeerConnectionStrategy(cacheSize int, minPeers int, dialTimeout time.Duration, backoff backoff.BackoffFactory, logger *zap.Logger) (*PeerConnectionStrategy, error)
NewPeerConnectionStrategy creates a utility to connect to peers, but only if we have not recently tried connecting to them already. cacheSize is the size of a TwoQueueCache dialTimeout is how long we attempt to connect to a peer before giving up minPeers is the minimum number of peers that the node should have backoff describes the strategy used to decide how long to backoff after previously attempting to connect to a peer
func (*PeerConnectionStrategy) PeerChannel ¶ added in v0.4.0
func (c *PeerConnectionStrategy) PeerChannel() chan<- PeerData
PeerChannel exposes the channel on which discovered peers should be pushed
func (*PeerConnectionStrategy) SetHost ¶ added in v0.6.0
func (c *PeerConnectionStrategy) SetHost(h host.Host)
Sets the host to be able to mount or consume a protocol
func (*PeerConnectionStrategy) Start ¶ added in v0.4.0
func (c *PeerConnectionStrategy) Start(ctx context.Context) error
Start attempts to connect to the peers passed in by peerCh. Will not connect to peers if they are within the backoff period.
func (*PeerConnectionStrategy) Stop ¶ added in v0.4.0
func (c *PeerConnectionStrategy) Stop()