peer

package
v0.0.0-...-c8d95c1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotFast = errors.New("peer doesn't implement Fast extension")
View Source
var ErrCongested = errors.New("peer is congested")
View Source
var ErrMetadataIncomplete = errors.New("metadata incomplete")
View Source
var ErrRange = errors.New("value out of range")
View Source
var UploadEstimator, DownloadEstimator rate.AtomicEstimator

Functions

func ConfSet

func ConfSet(dst *bool, v ConfValue)

func NumUnchoking

func NumUnchoking() int

func Run

func Run(peer *Peer, torEvent chan<- TorEvent, torDone <-chan struct{},
	info []byte, bitmap bitmap.Bitmap, init []byte) error

Types

type ConfValue

type ConfValue int
const (
	ConfUnknown ConfValue = 0
	ConfFalse   ConfValue = 1
	ConfTrue    ConfValue = 2
)

func ConfGet

func ConfGet(v bool) ConfValue

type Peer

type Peer struct {
	Counter  uint32
	Id       hash.Hash
	IP       net.IP
	Port     uint32
	Incoming bool

	Info   []byte
	Pieces *piece.Pieces

	Event chan PeerEvent
	Done  chan struct{}

	Log *log.Logger
	// contains filtered or unexported fields
}

func New

func New(proxy string, conn net.Conn, ip net.IP, port int,
	incoming bool, result protocol.HandshakeResult) *Peer

func (*Peer) AmUnchoking

func (peer *Peer) AmUnchoking() bool

func (*Peer) CanMetadata

func (peer *Peer) CanMetadata() bool

func (*Peer) CanPex

func (peer *Peer) CanPex() bool

func (*Peer) Encrypted

func (p *Peer) Encrypted() bool

func (*Peer) GetBitmap

func (peer *Peer) GetBitmap() bitmap.Bitmap

func (*Peer) GetFast

func (peer *Peer) GetFast() []uint32

func (*Peer) GetHave

func (peer *Peer) GetHave(index uint32) bool

func (*Peer) GetPex

func (peer *Peer) GetPex() *pex.Peer

func (*Peer) GetPort

func (p *Peer) GetPort() int

func (*Peer) GetStats

func (peer *Peer) GetStats() *PeerStats

func (*Peer) GetStatus

func (peer *Peer) GetStatus() *PeerStatus

func (*Peer) Interested

func (peer *Peer) Interested() bool

func (*Peer) MultipathTCP

func (p *Peer) MultipathTCP() bool

func (*Peer) Unchoked

func (peer *Peer) Unchoked() bool

type PeerCancel

type PeerCancel struct {
	Chunk uint32
}

type PeerCancelPiece

type PeerCancelPiece struct {
	Index uint32
}

type PeerDone

type PeerDone struct {
}

type PeerEvent

type PeerEvent interface{}

type PeerGetBitmap

type PeerGetBitmap struct {
	Ch chan<- bitmap.Bitmap
}

type PeerGetFast

type PeerGetFast struct {
	Ch chan<- []uint32
}

type PeerGetHave

type PeerGetHave struct {
	Index uint32
	Ch    chan<- bool
}

type PeerGetMetadata

type PeerGetMetadata struct {
	Index uint32
}

type PeerGetPex

type PeerGetPex struct {
	Ch chan<- pex.Peer
}

type PeerGetStats

type PeerGetStats struct {
	Ch chan<- PeerStats
}

type PeerGetStatus

type PeerGetStatus struct {
	Ch chan<- PeerStatus
}

type PeerHave

type PeerHave struct {
	Index uint32
	Have  bool
}

type PeerInterested

type PeerInterested struct {
	Interested bool
}

type PeerMetadataComplete

type PeerMetadataComplete struct {
	Info []byte
}

type PeerPex

type PeerPex struct {
	Peers []pex.Peer
	Add   bool
}

type PeerRequest

type PeerRequest struct {
	Chunks []uint32
}

type PeerStats

type PeerStats struct {
	Unchoked     bool
	Interested   bool
	AmUnchoking  bool
	AmInterested bool
	Seed         bool
	UploadOnly   bool
	HasProxy     bool
	Download     float64
	AvgDownload  float64
	Upload       float64
	Rtt          time.Duration
	Rttvar       time.Duration
	UnchokeTime  time.Time
	Rlen         int
	Qlen         int
	Ulen         int
	PieceCount   int
	NumPex       int
}

type PeerStatus

type PeerStatus struct {
	Unchoked     bool
	Interested   bool
	AmUnchoking  bool
	AmInterested bool
	Seed         bool
	UploadOnly   bool
	Qlen         int
	Download     float64
	AvgDownload  float64
	UnchokeTime  time.Time
}

type PeerUnchoke

type PeerUnchoke struct {
	Unchoke bool
}

type Requested

type Requested struct {
	Index, Begin, Length uint32
}

type TorAddKnown

type TorAddKnown struct {
	Peer    *Peer
	IP      net.IP
	Port    int
	Id      hash.Hash
	Version string
	Kind    known.Kind
}

type TorAddPeer

type TorAddPeer struct {
	Peer *Peer
	Init []byte
}

type TorAnnounce

type TorAnnounce struct {
	IPv6 bool
}

type TorBadPeer

type TorBadPeer struct {
	Peer uint32
	Bad  bool
}

type TorConf

type TorConf struct {
	UseDht      ConfValue
	DhtPassive  ConfValue
	UseTrackers ConfValue
	UseWebseeds ConfValue
}

type TorData

type TorData struct {
	Peer                 *Peer
	Index, Begin, Length uint32
	Complete             bool
}

type TorDrop

type TorDrop struct {
	Index, Begin, Length uint32
}

type TorDropPeer

type TorDropPeer struct {
	Ch chan<- bool
}

type TorEvent

type TorEvent interface{}

type TorGetAvailable

type TorGetAvailable struct {
	Ch chan<- []uint16
}

type TorGetConf

type TorGetConf struct {
	Ch chan<- TorConf
}

type TorGetKnown

type TorGetKnown struct {
	Id   hash.Hash
	IP   net.IP
	Port int
	Ch   chan<- known.Peer
}

type TorGetKnowns

type TorGetKnowns struct {
	Ch chan<- []known.Peer
}

type TorGetPeer

type TorGetPeer struct {
	Id hash.Hash
	Ch chan<- *Peer
}

type TorGetPeers

type TorGetPeers struct {
	Ch chan<- []*Peer
}

type TorGetStats

type TorGetStats struct {
	Ch chan<- *TorStats
}

type TorGoAway

type TorGoAway struct {
}

type TorHave

type TorHave struct {
	Index uint32
	Have  bool
}

type TorMetaData

type TorMetaData struct {
	Peer        *Peer
	Size, Index uint32
	Data        []byte
}

type TorPeerBitmap

type TorPeerBitmap struct {
	Peer   *Peer
	Bitmap bitmap.Bitmap
	Have   bool
}

type TorPeerExtended

type TorPeerExtended struct {
	Peer         *Peer
	MetadataSize uint32
}

type TorPeerGoaway

type TorPeerGoaway struct {
	Peer *Peer
}

type TorPeerHave

type TorPeerHave struct {
	Peer  *Peer
	Index uint32
	Have  bool
}

type TorPeerInterested

type TorPeerInterested struct {
	Peer       *Peer
	Interested bool
}

type TorPeerUnchoke

type TorPeerUnchoke struct {
	Peer    *Peer
	Unchoke bool
}

type TorRequest

type TorRequest struct {
	Index    uint32
	Priority int8
	Request  bool
	Ch       chan<- <-chan struct{}
}

type TorSetConf

type TorSetConf struct {
	Conf TorConf
	Ch   chan<- struct{}
}

type TorStats

type TorStats struct {
	Length      int64
	PieceLength uint32
	NumPeers    int
	NumKnown    int
	NumTrackers int
	NumWebseeds int
}

Directories

Path Synopsis
Package requests implements a queue of pending requests.
Package requests implements a queue of pending requests.

Jump to

Keyboard shortcuts

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