peer

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 17 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 peersource.Source

	Bitfield    *bitfield.Bitfield
	AllowedFast pieceset.PieceSet

	ID                [20]byte
	ExtensionsEnabled bool
	FastEnabled       bool
	DHTEnabled        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(conn net.Conn, source peersource.Source, id [20]byte, extensions [8]byte, cipher mse.CryptoMethod, pieceReadTimeout, snubTimeout time.Duration, maxRequestsIn int, br, bw *ratelimit.Bucket) *Peer

func (*Peer) CancelPiece added in v0.5.0

func (p *Peer) CancelPiece(index, begin, length uint32)

func (*Peer) Choke added in v0.4.9

func (p *Peer) Choke()

func (*Peer) Choking added in v0.4.9

func (p *Peer) Choking() bool

func (*Peer) Client added in v0.5.4

func (p *Peer) Client() string

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() int

func (*Peer) EnabledFast added in v0.5.4

func (p *Peer) EnabledFast() bool

func (*Peer) Interested added in v0.4.9

func (p *Peer) Interested() bool

func (*Peer) MetadataSize added in v0.5.0

func (p *Peer) MetadataSize() uint32

func (*Peer) Optimistic added in v0.4.9

func (p *Peer) Optimistic() bool

func (*Peer) RequestMetadataPiece added in v0.5.0

func (p *Peer) RequestMetadataPiece(index uint32)

func (*Peer) RequestPiece added in v0.5.0

func (p *Peer) RequestPiece(index, begin, length uint32)

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) SetOptimistic added in v0.4.9

func (p *Peer) SetOptimistic(value bool)

func (*Peer) StartPEX

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

func (*Peer) StopSnubTimer

func (p *Peer) StopSnubTimer()

func (*Peer) Unchoke added in v0.4.9

func (p *Peer) Unchoke()

func (*Peer) UploadSpeed added in v0.3.0

func (p *Peer) UploadSpeed() int

type PieceMessage

type PieceMessage struct {
	*Peer
	Piece peerreader.Piece
}

Jump to

Keyboard shortcuts

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