Documentation
¶
Index ¶
- func NewLocalEnode(config Config, key *ecdsa.PrivateKey) (*enode.LocalNode, *enode.DB, error)
- func NewTCPNode(cfg Config, key *ecdsa.PrivateKey, connGater ConnGater, ...) (host.Host, error)
- func NewUDPNode(config Config, ln *enode.LocalNode, key *ecdsa.PrivateKey, enrs []enr.Record, ...) (*discover.UDPv5, error)
- func ShortID(p peer.ID) string
- func StartPingService(host host.Host, peers []peer.ID, callback func(peer.ID)) context.CancelFunc
- type Config
- type ConnGater
- func (c ConnGater) InterceptAccept(_ network.ConnMultiaddrs) (allow bool)
- func (c ConnGater) InterceptAddrDial(_ peer.ID, addr multiaddr.Multiaddr) (allow bool)
- func (c ConnGater) InterceptPeerDial(_ peer.ID) (allow bool)
- func (c ConnGater) InterceptSecured(_ network.Direction, id peer.ID, _ network.ConnMultiaddrs) bool
- func (c ConnGater) InterceptUpgraded(_ network.Conn) (bool, control.DisconnectReason)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLocalEnode ¶ added in v0.1.1
NewLocalEnode returns a local enode and a peer DB or an error.
func NewTCPNode ¶ added in v0.1.1
func NewTCPNode(cfg Config, key *ecdsa.PrivateKey, connGater ConnGater, udpNode *discover.UDPv5, manifest cluster.Manifest) (host.Host, error)
NewTCPNode returns a started tcp-based libp2p node.
func NewUDPNode ¶ added in v0.1.1
func NewUDPNode(config Config, ln *enode.LocalNode, key *ecdsa.PrivateKey, enrs []enr.Record, excludeENRs bool) (*discover.UDPv5, error)
NewUDPNode starts and returns a discv5 UDP implementation.
func ShortID ¶ added in v0.1.1
ShortID returns the short ID string of the peer ID. It was inspired by peer.ID.ShortString() but even shorter.
func StartPingService ¶ added in v0.1.1
StartPingService stars a p2p ping service that pings all peers every second and collects metrics. TODO(corver): Cluster wide req/resp doesn't scale since it is O(n^2).
Types ¶
type Config ¶
type Config struct { // DBPath defines the discv5 peer database file path. DBPath string // UDPBootnodes defines the discv5 boot node URLs (in addition to manifest ENRs). UDPBootnodes []string // UDPAddr defines the discv5 udp listen address. UDPAddr string // TCPAddrs defines the lib-p2p tcp listen addresses. TCPAddrs []string // Allowlist defines csv CIDR blocks for lib-p2p allowed connections. Allowlist string // Allowlist defines csv CIDR blocks for lib-p2p denied connections. Denylist string }
func (Config) Multiaddrs ¶
Multiaddrs returns the configured addresses as libp2p multiaddrs.
type ConnGater ¶
type ConnGater struct {
// contains filtered or unexported fields
}
ConnGater filters incoming connections by the cluster peers.
func NewConnGater ¶ added in v0.1.1
NewConnGater return a new connection gater that limits access to the cluster peers.
func (ConnGater) InterceptAccept ¶
func (c ConnGater) InterceptAccept(_ network.ConnMultiaddrs) (allow bool)
func (ConnGater) InterceptAddrDial ¶
func (ConnGater) InterceptPeerDial ¶
InterceptPeerDial does nothing.
func (ConnGater) InterceptSecured ¶
InterceptSecured rejects nodes with a peer ID that isn't part of any known DV.
func (ConnGater) InterceptUpgraded ¶
InterceptUpgraded does nothing.