Documentation ¶
Overview ¶
Package transport defines the libp2p webmesh transport.
Index ¶
- func New(opts Options) (TransportBuilder, *WebmeshTransport)
- type Options
- type Transport
- type TransportBuilder
- type WebmeshTransport
- func (t *WebmeshTransport) BroadcastAddrs(addrs []ma.Multiaddr) []ma.Multiaddr
- func (t *WebmeshTransport) CanDial(addr ma.Multiaddr) bool
- func (t *WebmeshTransport) Close() error
- func (t *WebmeshTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
- func (t *WebmeshTransport) Listen(laddr ma.Multiaddr) (transport.Listener, error)
- func (t *WebmeshTransport) Protocols() []int
- func (t *WebmeshTransport) Proxy() bool
- func (t *WebmeshTransport) Resolve(ctx context.Context, maddr ma.Multiaddr) ([]ma.Multiaddr, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(opts Options) (TransportBuilder, *WebmeshTransport)
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 ¶
func (t *WebmeshTransport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
Dial dials a remote peer. It should try to reuse local listener addresses if possible, but it may choose not to.
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.