peer

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(params HandlerParams) error

for Handle doesn't matter outgoing or incoming Connection, it just send and receive messages

Types

type Connected

type Connected struct {
	Peer Peer
}

type Direction

type Direction int
const Incoming Direction = 1
const Outgoing Direction = 2

func (Direction) String

func (a Direction) String() string

type DuplicateChecker added in v0.8.1

type DuplicateChecker interface {
	Add([]byte) (isNew bool)
}

type HandlerParams

type HandlerParams struct {
	Ctx              context.Context
	ID               string
	Connection       conn.Connection
	Remote           Remote
	Parent           Parent
	Pool             bytespool.Pool
	Peer             Peer
	DuplicateChecker DuplicateChecker
}

type InfoMessage

type InfoMessage struct {
	Peer  Peer
	Value interface{}
}

type Parent

type Parent struct {
	MessageCh chan ProtoMessage
	InfoCh    chan InfoMessage
}

func NewParent

func NewParent() Parent

type Peer

type Peer interface {
	Direction() Direction
	Close() error
	SendMessage(proto.Message)
	ID() string
	Connection() conn.Connection
	Handshake() proto.Handshake
	RemoteAddr() proto.TCPAddr
}

type PeerImpl

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

func NewPeerImpl

func NewPeerImpl(handshake proto.Handshake, conn conn.Connection, direction Direction, remote Remote, cancel context.CancelFunc) *PeerImpl

func (*PeerImpl) Close

func (a *PeerImpl) Close() error

func (*PeerImpl) Connection

func (a *PeerImpl) Connection() conn.Connection

func (*PeerImpl) Direction

func (a *PeerImpl) Direction() Direction

func (*PeerImpl) Handshake

func (a *PeerImpl) Handshake() proto.Handshake

func (*PeerImpl) ID

func (a *PeerImpl) ID() string

func (*PeerImpl) RemoteAddr

func (a *PeerImpl) RemoteAddr() proto.TCPAddr

func (*PeerImpl) SendMessage

func (a *PeerImpl) SendMessage(m proto.Message)

type ProtoMessage

type ProtoMessage struct {
	ID      Peer
	Message proto.Message
}

type Remote

type Remote struct {
	ToCh   chan []byte
	FromCh chan []byte
	ErrCh  chan error
}

func NewRemote

func NewRemote() Remote

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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