Documentation ¶
Index ¶
- Variables
- func NewConnectionGater(logger *zap.Logger, atLimit func() bool, isBadPeerF BadPeerF) connmgr.ConnectionGater
- type BadPeerF
- type ConnHandler
- type HandshakeFilter
- func BadPeerFilter(logger *zap.Logger, n peers.Index) HandshakeFilter
- func NetworkIDFilter(networkID string) HandshakeFilter
- func RegisteredOperatorsFilter(nodeStorage storage.Storage, keysConfigWhitelist []string) HandshakeFilter
- func SenderRecipientIPsCheckFilter(me peer.ID) HandshakeFilter
- func SignatureCheckFilter() HandshakeFilter
- type Handshaker
- type HandshakerCfg
- type Metrics
- type SubnetsProvider
Constants ¶
This section is empty.
Variables ¶
var AllowedDifference = 30 * time.Second
Functions ¶
func NewConnectionGater ¶
func NewConnectionGater(logger *zap.Logger, atLimit func() bool, isBadPeerF BadPeerF) connmgr.ConnectionGater
NewConnectionGater creates a new instance of ConnectionGater
Types ¶
type ConnHandler ¶
type ConnHandler interface {
Handle(logger *zap.Logger) *libp2pnetwork.NotifyBundle
}
ConnHandler handles new connections (inbound / outbound) using libp2pnetwork.NotifyBundle
func NewConnHandler ¶
func NewConnHandler( ctx context.Context, handshaker Handshaker, subnetsProvider SubnetsProvider, subnetsIndex peers.SubnetsIndex, connIdx peers.ConnectionIndex, peerInfos peers.PeerInfoIndex, mr Metrics, ) ConnHandler
NewConnHandler creates a new connection handler
type HandshakeFilter ¶
type HandshakeFilter func(senderID peer.ID, sni records.AnyNodeInfo) error
HandshakeFilter can be used to filter nodes once we handshaked with them
func BadPeerFilter ¶ added in v1.3.10
func BadPeerFilter(logger *zap.Logger, n peers.Index) HandshakeFilter
BadPeerFilter avoids connecting to a bad peer
func NetworkIDFilter ¶
func NetworkIDFilter(networkID string) HandshakeFilter
NetworkIDFilter determines whether we will connect to the given node by the network ID
func RegisteredOperatorsFilter ¶ added in v1.1.0
func RegisteredOperatorsFilter(nodeStorage storage.Storage, keysConfigWhitelist []string) HandshakeFilter
func SenderRecipientIPsCheckFilter ¶ added in v1.1.0
func SenderRecipientIPsCheckFilter(me peer.ID) HandshakeFilter
func SignatureCheckFilter ¶ added in v1.1.0
func SignatureCheckFilter() HandshakeFilter
type Handshaker ¶
type Handshaker interface { Handshake(logger *zap.Logger, conn libp2pnetwork.Conn) error Handler(logger *zap.Logger) libp2pnetwork.StreamHandler }
Handshaker is the interface for handshaking with peers. it uses node info protocol to exchange information with other nodes and decide whether we want to connect.
NOTE: due to compatibility with v0, we accept nodes with user agent as a fallback when the new protocol is not supported.
func NewHandshaker ¶
func NewHandshaker(ctx context.Context, cfg *HandshakerCfg, filters func() []HandshakeFilter) Handshaker
NewHandshaker creates a new instance of handshaker
type HandshakerCfg ¶
type HandshakerCfg struct { Network libp2pnetwork.Network Streams streams.StreamController NodeInfos peers.NodeInfoIndex PeerInfos peers.PeerInfoIndex ConnIdx peers.ConnectionIndex SubnetsIdx peers.SubnetsIndex IDService identify.IDService OperatorSigner keys.OperatorSigner SubnetsProvider SubnetsProvider Permissioned func() bool }
HandshakerCfg is the configuration for creating an handshaker instance
type SubnetsProvider ¶
SubnetsProvider returns the subnets of or node