peer

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	*Peer
	Message interface{}
}

type Peer

type Peer struct {
	*peerconn.Conn

	ConnectedAt time.Time

	Source Source

	Bitfield    *bitfield.Bitfield
	AllowedFast pieceset.PieceSet

	ID                [20]byte
	ExtensionsEnabled bool
	FastEnabled       bool
	EncryptionCipher  mse.CryptoMethod

	ClientInterested bool
	ClientChoking    bool
	PeerInterested   bool
	PeerChoking      bool

	OptimisticUnchoked bool

	// Snubbed means peer is sending pieces too slow.
	Snubbed bool

	Downloading bool

	// Messages received while we don't have info yet are saved here.
	Messages []interface{}

	ExtensionHandshake *peerprotocol.ExtensionHandshakeMessage

	PEX *pex
	// contains filtered or unexported fields
}

func New

func New(p *peerconn.Conn, source Source, id [20]byte, extensions [8]byte, cipher mse.CryptoMethod, snubTimeout time.Duration) *Peer

func (*Peer) Close

func (p *Peer) Close()

func (*Peer) Done added in v0.3.8

func (p *Peer) Done() chan struct{}

func (*Peer) DownloadSpeed added in v0.3.0

func (p *Peer) DownloadSpeed() uint

func (*Peer) ResetSnubTimer

func (p *Peer) ResetSnubTimer()

func (*Peer) Run

func (p *Peer) Run(messages chan Message, pieces chan interface{}, snubbed, disconnect chan *Peer)

func (*Peer) StartPEX

func (p *Peer) StartPEX(initialPeers map[*Peer]struct{})

func (*Peer) StopSnubTimer

func (p *Peer) StopSnubTimer()

func (*Peer) UploadSpeed added in v0.3.0

func (p *Peer) UploadSpeed() uint

type PieceMessage

type PieceMessage struct {
	*Peer
	Piece peerreader.Piece
}

type Source added in v0.3.0

type Source int
const (
	SourceTracker Source = iota
	SourceDHT
	SourcePEX
	SourceManual
	SourceIncoming
)

func (Source) String added in v0.3.0

func (s Source) String() string

Jump to

Keyboard shortcuts

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