libp2p

package
v0.0.0-...-7d840d9 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 35 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
}

type CrawlDriver

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

func NewCrawlDriver

func NewCrawlDriver(dbc db.Client, dbCrawl *models.Crawl, 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
	Network        config.Network
	Protocols      []string
	DialTimeout    time.Duration
	TrackNeighbors bool
	CheckExposed   bool
	BootstrapPeers []peer.AddrInfo
	AddrTrackType  config.AddrType
	AddrDialType   config.AddrType
	MeterProvider  metric.MeterProvider
	TracerProvider trace.TracerProvider
	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 {
	TrackNeighbors bool
	DialTimeout    time.Duration
	CheckExposed   bool
	AddrDialType   config.AddrType
	LogErrors      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.DBClient, 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 interface {
	host.Host
	IDService() identify.IDService
}

Host is the interface that's required for crawling libp2p peers. Actually the *basichost.Host is required but to allow testing we define this interface here. That allows us to inject a mock host.

type P2PResult

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

	// 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

	// All connections 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.
	ListenAddrs []ma.Multiaddr

	// If the connection was closed immediately
	ConnClosedImmediately bool
}

type PeerInfo

type PeerInfo struct {
	peer.AddrInfo
}

func (PeerInfo) Addrs

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

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