libp2p

package
v0.0.0-...-2ace7f4 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResult

type APIResult struct {
	// Indicates if we actually found IP addresses to probe
	Attempted bool

	// The ID response object from the Kubo API
	ID *kubo.IDResponse

	// The Kubo routing table. Doesn't contain multi addresses. Don't use this to continue crawling.
	RoutingTable *kubo.RoutingTableResponse

	// The multiaddress that contained the IP over which we successfully connected to the API
	ConnectMaddr ma.Multiaddr
}

func (*APIResult) ListenMaddrs

func (r *APIResult) ListenMaddrs() []ma.Multiaddr

type CrawlDriver

type CrawlDriver struct {
	// contains filtered or unexported fields
}

func NewCrawlDriver

func NewCrawlDriver(dbc db.Client, cfg *CrawlDriverConfig) (*CrawlDriver, error)

func (*CrawlDriver) Close

func (d *CrawlDriver) Close()

func (*CrawlDriver) NewWorker

func (*CrawlDriver) NewWriter

func (*CrawlDriver) Tasks

func (d *CrawlDriver) Tasks() <-chan PeerInfo

type CrawlDriverConfig

type CrawlDriverConfig struct {
	Version        string
	WorkerCount    int
	Network        config.Network
	Protocols      []string
	DialTimeout    time.Duration
	CheckExposed   bool
	BootstrapPeers []peer.AddrInfo
	AddrDialType   config.AddrType
	MeterProvider  metric.MeterProvider
	TracerProvider trace.TracerProvider
	GossipSubPX    bool
	LogErrors      bool
}

func (*CrawlDriverConfig) CrawlerConfig

func (cfg *CrawlDriverConfig) CrawlerConfig() *CrawlerConfig

func (*CrawlDriverConfig) WriterConfig

func (cfg *CrawlDriverConfig) WriterConfig() *core.CrawlWriterConfig

type Crawler

type Crawler struct {
	// contains filtered or unexported fields
}

func (*Crawler) Work

func (c *Crawler) Work(ctx context.Context, task PeerInfo) (core.CrawlResult[PeerInfo], error)

type CrawlerConfig

type CrawlerConfig struct {
	DialTimeout  time.Duration
	CheckExposed bool
	AddrDialType config.AddrType
	LogErrors    bool
	GossipSubPX  bool
	Clock        clock.Clock
}

func DefaultCrawlerConfig

func DefaultCrawlerConfig() *CrawlerConfig

type DialDriver

type DialDriver struct {
	// contains filtered or unexported fields
}

func NewDialDriver

func NewDialDriver(dbc db.Client, cfg *DialDriverConfig) (*DialDriver, error)

func (*DialDriver) Close

func (d *DialDriver) Close()

func (*DialDriver) NewWorker

func (d *DialDriver) NewWorker() (core.Worker[PeerInfo, core.DialResult[PeerInfo]], error)

func (*DialDriver) NewWriter

func (*DialDriver) Tasks

func (d *DialDriver) Tasks() <-chan PeerInfo

type DialDriverConfig

type DialDriverConfig struct {
	Version     string
	DialTimeout time.Duration
}

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

Dialer encapsulates a libp2p host that dials peers.

func (*Dialer) Work

func (d *Dialer) Work(ctx context.Context, task PeerInfo) (core.DialResult[PeerInfo], error)

Work TODO

type Host

type Host struct {
	host.Host
	// contains filtered or unexported fields
}

Host wraps a regular libp2p host and exposes additional methods to register peers to receive Identify exchange events. TODO: I'm not quite happy with all the locking going on here...

func WrapHost

func WrapHost(h host.Host) (*Host, error)

WrapHost wraps the given host to allow for registering peers for Identify events.

func (*Host) Close

func (h *Host) Close() error

func (*Host) DeregisterIdentify

func (h *Host) DeregisterIdentify(pid peer.ID)

DeregisterIdentify deregisters the given peer and closes the channel which was previously returned in [RegisterIdentify]

func (*Host) RegisterIdentify

func (h *Host) RegisterIdentify(pid peer.ID) <-chan event.EvtPeerIdentificationCompleted

RegisterIdentify registers the given peer to receive the corresponding Identify events. The returned channel will emit the event.EvtPeerIdentificationCompleted event or be closed without an event in case of an error. The returned channel will emit at most one event.

type P2PResult

type P2PResult struct {
	RoutingTable *core.RoutingTable[PeerInfo]

	// All multi addresses that the remote peer claims to listen on
	// this can be different from the ones that we received from another peer
	// e.g., they could miss quic-v1 addresses if the reporting peer doesn't
	// know about that protocol.
	ListenMaddrs []ma.Multiaddr

	// The agent version of the crawled peer
	Agent string

	// The protocols the peer supports
	Protocols []string

	// Any error that has occurred when connecting to the peer
	ConnectError error

	// The above error transferred to a known error
	ConnectErrorStr string

	// Any error that has occurred during fetching neighbor information
	CrawlError error

	// The above error transferred to a known error
	CrawlErrorStr string

	// When was the connection attempt made
	ConnectStartTime time.Time

	// When have we established a successful connection
	ConnectEndTime time.Time

	// The multiaddress of the successful connection
	ConnectMaddr ma.Multiaddr

	// the transport of a successful connection
	Transport string
}

type PeerInfo

type PeerInfo struct {
	peer.AddrInfo
}

func (PeerInfo) Addrs

func (p PeerInfo) Addrs() []ma.Multiaddr

func (PeerInfo) DeduplicationKey

func (p PeerInfo) DeduplicationKey() string

func (PeerInfo) DiscoveryPrefix

func (p PeerInfo) DiscoveryPrefix() uint64

func (PeerInfo) ID

func (p PeerInfo) ID() peer.ID

func (PeerInfo) Merge

func (p PeerInfo) Merge(other PeerInfo) PeerInfo

Jump to

Keyboard shortcuts

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