go-ipfs: github.com/ipfs/go-ipfs/p2p Index | Files

package p2p

import "github.com/ipfs/go-ipfs/p2p"


Package Files

listener.go local.go p2p.go remote.go stream.go

type Listener Uses

type Listener interface {
    Protocol() protocol.ID
    ListenAddress() ma.Multiaddr
    TargetAddress() ma.Multiaddr
    // contains filtered or unexported methods

Listener listens for connections and proxies them to a target

type Listeners Uses

type Listeners struct {

    Listeners map[string]Listener

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

func (*Listeners) Close Uses

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

func (*Listeners) Register Uses

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

Register registers listenerInfo into this registry and starts it

type P2P Uses

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 Uses

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

New creates new P2P struct

func (*P2P) CheckProtoExists Uses

func (p2p *P2P) CheckProtoExists(proto string) bool

CheckProtoExists checks whether a proto handler is registered to mux handler

func (*P2P) ForwardLocal Uses

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 Uses

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

ForwardRemote creates new p2p listener

type Stream Uses

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 Uses

type StreamRegistry struct {

    Streams map[uint64]*Stream

    // contains filtered or unexported fields

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

func (*StreamRegistry) Close Uses

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

Close stream endpoints and deregister it

func (*StreamRegistry) Deregister Uses

func (r *StreamRegistry) Deregister(streamID uint64)

Deregister deregisters stream from the registry

func (*StreamRegistry) Register Uses

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

Register registers a stream to the registry

func (*StreamRegistry) Reset Uses

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

Reset closes stream endpoints and deregisters it

Package p2p imports 16 packages (graph) and is imported by 50 packages. Updated 2020-10-04. Refresh now. Tools for package owners.