Documentation ¶
Overview ¶
Package discovery provides functionalities to discover peers in a libp2p network using a Distributed Hash Table (DHT) and mDNS.
Package discovery provides functionality for peer discovery in a libp2p network.
Index ¶
- func CleanUpPeers(ctx context.Context, host host.Host, cfg *config.Config)
- func FilterOutPrivateAddrs(addrs []ma.Multiaddr) []ma.Multiaddr
- func GeneratePacket(hostID peer.ID) []byte
- func NATDiscovery(log *ipfsLog.ZapEventLogger) bool
- func NewPeerSource(log *ipfsLog.ZapEventLogger, hostGetter func() host.Host) autorelay.PeerSource
- func Ping(ctx context.Context, host host.Host, randomInterval int64)
- type DHT
- type MDNS
- type Packet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanUpPeers ¶
FIXME: This function does not work as intended. It should remove peers from the peerstore if they are unreachable.
func FilterOutPrivateAddrs ¶
FilterOutPrivateAddrs filters out private IP addresses from a list of multiaddresses.
func GeneratePacket ¶
func NATDiscovery ¶
func NATDiscovery(log *ipfsLog.ZapEventLogger) bool
func NewPeerSource ¶
func NewPeerSource(log *ipfsLog.ZapEventLogger, hostGetter func() host.Host) autorelay.PeerSource
Types ¶
type DHT ¶
type DHT struct { BootstrapNode bool // Indicates if the node is a bootstrap node. RendezvousString string // Used for identifying peers in the network. BootstrapPeers []multiaddr.Multiaddr // List of initial peers to connect to. DiscorveryRefreshInterval time.Duration // Interval to refresh discovery. IgnoredPeers map[peer.ID]bool // Set of peers to ignore during discovery. *dht.IpfsDHT // Embedded IPFS DHT instance. }
DHT encapsulates the functionalities of a Distributed Hash Table for peer discovery in a libp2p network.
func NewDHTDiscovery ¶
type MDNS ¶
type MDNS struct {
Rendezvous string // Rendezvous string used to identify peers in the mDNS service.
}
MDNS struct encapsulates the parameters for mDNS-based peer discovery.
func NewMDNSDiscovery ¶
NewMDNSDiscovery creates a new MDNS discovery instance with the specified rendezvous string.