p2p

package
v0.43.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 16 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener interface {
	Protocol() protocol.ID
	ListenAddress() ma.Multiaddr
	TargetAddress() ma.Multiaddr

	// Done returns a channel that is closed when the listener is closed.
	// This allows callers to detect when a listener has been removed.
	Done() <-chan struct{}
	// contains filtered or unexported methods
}

Listener listens for connections and proxies them to a target.

type Listeners added in v0.4.18

type Listeners struct {
	sync.RWMutex

	Listeners map[protocol.ID]Listener
}

Listeners manages a group of Listener implementations, checking for conflicts and optionally dispatching connections.

func (*Listeners) Close added in v0.4.18

func (r *Listeners) Close(matchFunc func(listener Listener) bool) int

Close removes and closes all listeners for which matchFunc returns true. Returns the number of listeners closed.

func (*Listeners) Register added in v0.4.18

func (r *Listeners) Register(l Listener) error

Register registers listenerInfo into this registry and starts it.

type P2P

type P2P struct {
	ListenersLocal *Listeners
	ListenersP2P   *Listeners
	Streams        *StreamRegistry
	// contains filtered or unexported fields
}

P2P structure holds information on currently running streams/Listeners.

func New added in v0.14.0

func New(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *P2P

New creates new P2P struct.

func (*P2P) CheckProtoExists

func (p2p *P2P) CheckProtoExists(proto protocol.ID) bool

CheckProtoExists checks whether a proto handler is registered to mux handler.

func (*P2P) ForwardLocal added in v0.4.18

func (p2p *P2P) ForwardLocal(ctx context.Context, peer peer.ID, proto protocol.ID, bindAddr ma.Multiaddr) (Listener, error)

ForwardLocal creates new P2P stream to a remote listener.

func (*P2P) ForwardRemote added in v0.4.18

func (p2p *P2P) ForwardRemote(ctx context.Context, proto protocol.ID, addr ma.Multiaddr, reportRemote bool) (Listener, error)

ForwardRemote creates new p2p listener.

type Stream added in v0.4.18

type Stream struct {
	Protocol protocol.ID

	OriginAddr ma.Multiaddr
	TargetAddr ma.Multiaddr

	Local  manet.Conn
	Remote net.Stream

	Registry *StreamRegistry
	// contains filtered or unexported fields
}

Stream holds information on active incoming and outgoing p2p streams.

type StreamRegistry

type StreamRegistry struct {
	sync.Mutex

	Streams map[uint64]*Stream

	ifconnmgr.ConnManager
	// contains filtered or unexported fields
}

StreamRegistry is a collection of active incoming and outgoing proto app streams.

func (*StreamRegistry) Close added in v0.4.18

func (r *StreamRegistry) Close(s *Stream)

Close stream endpoints and deregister it.

func (*StreamRegistry) Deregister

func (r *StreamRegistry) Deregister(streamID uint64)

Deregister deregisters stream from the registry.

func (*StreamRegistry) Register

func (r *StreamRegistry) Register(streamInfo *Stream)

Register registers a stream to the registry.

func (*StreamRegistry) Reset added in v0.4.18

func (r *StreamRegistry) Reset(s *Stream)

Reset closes stream endpoints and deregisters it.

Jump to

Keyboard shortcuts

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