p2p

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PinPeers

func PinPeers(clusters *cluster.KnownClusters, connMgr connmgr.ConnManager) error

PinPeers marks all DV peers as protected peers, preventing disconnects.

Types

type Config

type Config struct {
	IPAddrs []net.IP
	Port    int
	Netlist *netutil.Netlist
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig constructs P2P config using viper.

func (*Config) IPv4

func (c *Config) IPv4() net.IP

IPv4 returns the first configured IPv4 address or nil.

func (*Config) IPv6

func (c *Config) IPv6() net.IP

IPv6 returns the first configured IPv6 address or nil.

func (*Config) Multiaddrs

func (c *Config) Multiaddrs() (addrs []multiaddr.Multiaddr, err error)

Multiaddrs returns the configured IP addresses as libp2p multiaddrs.

type ConnGater

type ConnGater struct {
	PeerIDs  map[peer.ID]struct{} // known nodes by libp2p peer ID
	Networks *netutil.Netlist
}

ConnGater filters incoming connections to known DV clients.

func NewConnGaterForClusters

func NewConnGaterForClusters(clusters cluster.KnownClusters, networks *netutil.Netlist) *ConnGater

NewConnGaterForClusters constructs a conn gater that limits access to nodes part of the provided clusters.

func (*ConnGater) InterceptAccept

func (c *ConnGater) InterceptAccept(_ network.ConnMultiaddrs) (allow bool)

func (*ConnGater) InterceptAddrDial

func (c *ConnGater) InterceptAddrDial(_ peer.ID, addr multiaddr.Multiaddr) (allow bool)

func (*ConnGater) InterceptPeerDial

func (c *ConnGater) InterceptPeerDial(_ peer.ID) (allow bool)

InterceptPeerDial does nothing.

func (*ConnGater) InterceptSecured

func (c *ConnGater) InterceptSecured(_ network.Direction, id peer.ID, _ network.ConnMultiaddrs) (allow bool)

InterceptSecured rejects nodes with a peer ID that isn't part of any known DV.

func (*ConnGater) InterceptUpgraded

func (c *ConnGater) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason)

InterceptUpgraded does nothing.

type Node

type Node struct {
	host.Host
}

func NewNode

func NewNode(cfg *Config, key *ecdsa.PrivateKey, connGater *ConnGater) (*Node, error)

NewNode starts the libp2p subsystem. TODO(corver): Remove pointer to config.

Jump to

Keyboard shortcuts

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