p2p

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

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

Go to latest
Published: Mar 16, 2019 License: MIT Imports: 16 Imported by: 0

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
	// contains filtered or unexported methods
}

侦听器侦听连接并将其代理到目标

type Listeners

type Listeners struct {
	sync.RWMutex

	Listeners map[string]Listener
}

侦听器管理一组侦听器实现, 检查冲突并可选地分派连接

func (*Listeners) Close

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

func (*Listeners) Register

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

将listenerinfo注册到这个注册表并启动它

type P2P

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

p2p结构保存当前运行的流/侦听器的信息

func NewP2P

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

new p2p创建新的p2p结构

func (*P2P) CheckProtoExists

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

checkprotoexists检查是否向注册了proto处理程序 多路复用器

func (*P2P) ForwardLocal

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

ForwardLocal为远程侦听器创建新的P2P流

func (*P2P) ForwardRemote

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

ForwardRemote创建新的P2P侦听器

type Stream

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
}

流保存有关活动的传入和传出P2P流的信息。

type StreamRegistry

type StreamRegistry struct {
	sync.Mutex

	Streams map[uint64]*Stream

	ifconnmgr.ConnManager
	// contains filtered or unexported fields
}

streamregistry是活动的传入和传出协议应用程序流的集合。

func (*StreamRegistry) Close

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

关闭流终结点并注销它

func (*StreamRegistry) Deregister

func (r *StreamRegistry) Deregister(streamID uint64)

注销从注册表注销流

func (*StreamRegistry) Register

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

注册将流注册到注册表

func (*StreamRegistry) Reset

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

重置关闭流终结点并注销它

Jump to

Keyboard shortcuts

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