transport

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package transport defines the libp2p webmesh transport.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New returns a new webmesh transport builder.

Types

type Options

type Options struct {
	// Config is the webmesh config.
	Config *config.Config
	// LogLevel is the log level for the webmesh transport.
	LogLevel string
	// StartTimeout is the timeout for starting the webmesh node.
	StartTimeout time.Duration
	// StopTimeout is the timeout for stopping the webmesh node.
	StopTimeout time.Duration
	// ListenTimeout is the timeout for starting a listener on the webmesh node.
	ListenTimeout time.Duration
	// Logger is the logger to use for the webmesh transport.
	// If nil, an empty logger will be used.
	Logger *slog.Logger
}

Options are the options for the webmesh transport.

type Transport

type Transport interface {
	// Closer for the underlying transport that shuts down the webmesh node.
	io.Closer
	// Transport is the underlying libp2p Transport.
	transport.Transport
	// Resolver is a resolver that uses the mesh storage to lookup peers.
	transport.Resolver
}

Transport is the webmesh transport.

type TransportBuilder

type TransportBuilder func(upgrader transport.Upgrader, host host.Host, rcmgr network.ResourceManager, privKey crypto.PrivKey) (Transport, error)

TransportBuilder is the signature of a function that builds a webmesh transport.

type WebmeshTransport

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

WebmeshTransport is the webmesh libp2p transport. It must be used with a webmesh keypair and security transport.

func (*WebmeshTransport) BroadcastAddrs

func (t *WebmeshTransport) BroadcastAddrs(addrs []ma.Multiaddr) []ma.Multiaddr

BroadcastAddrs implements AddrsFactory on top of this transport. It automatically appends our webmesh ID and any DNS addresses we have to the list of addresses.

func (*WebmeshTransport) CanDial

func (t *WebmeshTransport) CanDial(addr ma.Multiaddr) bool

CanDial returns true if this transport knows how to dial the given multiaddr.

Returning true does not guarantee that dialing this multiaddr will succeed. This function should *only* be used to preemptively filter out addresses that we can't dial.

func (*WebmeshTransport) Close

func (t *WebmeshTransport) Close() error

Close closes the transport.

func (*WebmeshTransport) Dial

Dial dials a remote peer. It should try to reuse local listener addresses if possible, but it may choose not to.

func (*WebmeshTransport) Listen

func (t *WebmeshTransport) Listen(laddr ma.Multiaddr) (transport.Listener, error)

Listen listens on the passed multiaddr.

func (*WebmeshTransport) Protocols

func (t *WebmeshTransport) Protocols() []int

Protocol returns the set of protocols handled by this transport.

func (*WebmeshTransport) Proxy

func (t *WebmeshTransport) Proxy() bool

Proxy returns true if this is a proxy transport.

func (*WebmeshTransport) Resolve

func (t *WebmeshTransport) Resolve(ctx context.Context, maddr ma.Multiaddr) ([]ma.Multiaddr, error)

Resolve attempts to resolve the given multiaddr to a list of addresses.

Jump to

Keyboard shortcuts

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