connections

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllowedDifference = 30 * time.Second

Functions

func NewConnectionGater

func NewConnectionGater(logger *zap.Logger, atLimit func() bool) 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 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 Metrics added in v1.2.2

type Metrics interface {
	PeerDisconnected(peer.ID)
}

type SubnetsProvider

type SubnetsProvider func() records.Subnets

SubnetsProvider returns the subnets of or node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL