peerprotocol

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExtensionIDHandshake = iota
	ExtensionIDMetadata
	ExtensionIDPEX
)
View Source
const (
	ExtensionKeyMetadata = "ut_metadata"
	ExtensionKeyPEX      = "ut_pex"
)
View Source
const (
	ExtensionMetadataMessageTypeRequest = iota
	ExtensionMetadataMessageTypeData
	ExtensionMetadataMessageTypeReject
)
View Source
const (
	Choke MessageID = iota
	Unchoke
	Interested
	NotInterested
	Have
	Bitfield
	Request
	Piece
	Cancel
	Port
	Suggest     = 13
	HaveAll     = 14
	HaveNone    = 15
	Reject      = 16
	AllowedFast = 17
	Extension   = 20
)

Peer message types

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowedFastMessage

type AllowedFastMessage struct{ HaveMessage }

type BitfieldMessage

type BitfieldMessage struct {
	Data []byte
	// contains filtered or unexported fields
}

func (BitfieldMessage) ID

func (m BitfieldMessage) ID() MessageID

func (*BitfieldMessage) Read added in v0.4.5

func (m *BitfieldMessage) Read(b []byte) (n int, err error)

type CancelMessage

type CancelMessage struct{ RequestMessage }

func (CancelMessage) ID

func (m CancelMessage) ID() MessageID

type ChokeMessage

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

func (ChokeMessage) ID

func (m ChokeMessage) ID() MessageID

func (ChokeMessage) Read added in v0.4.5

func (m ChokeMessage) Read(b []byte) (int, error)

type ExtensionHandshakeMessage

type ExtensionHandshakeMessage struct {
	M            map[string]uint8 `bencode:"m"`
	V            string           `bencode:"v"`
	YourIP       string           `bencode:"yourip,omitempty"`
	MetadataSize int              `bencode:"metadata_size,omitempty"`
	RequestQueue int              `bencode:"reqq"`
}

func NewExtensionHandshake

func NewExtensionHandshake(metadataSize uint32, version string, yourip net.IP, requestQueueLength int) ExtensionHandshakeMessage

type ExtensionMessage

type ExtensionMessage struct {
	ExtendedMessageID uint8
	Payload           interface{}
}

func (ExtensionMessage) ID

func (m ExtensionMessage) ID() MessageID

func (ExtensionMessage) Read added in v0.4.5

func (m ExtensionMessage) Read([]byte) (int, error)

func (*ExtensionMessage) UnmarshalBinary

func (m *ExtensionMessage) UnmarshalBinary(data []byte) error

func (ExtensionMessage) WriteTo added in v0.4.4

func (m ExtensionMessage) WriteTo(w io.Writer) (n int64, err error)

type ExtensionMetadataMessage

type ExtensionMetadataMessage struct {
	Type      int    `bencode:"msg_type"`
	Piece     uint32 `bencode:"piece"`
	TotalSize int    `bencode:"total_size,omitempty"`
	Data      []byte `bencode:"-"`
}

type ExtensionPEXMessage

type ExtensionPEXMessage struct {
	Added   string `bencode:"added"`
	Dropped string `bencode:"dropped"`
}

type HaveAllMessage

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

func (HaveAllMessage) ID

func (m HaveAllMessage) ID() MessageID

func (HaveAllMessage) Read added in v0.4.5

func (m HaveAllMessage) Read(b []byte) (int, error)

type HaveMessage

type HaveMessage struct {
	Index uint32
}

func (HaveMessage) ID

func (m HaveMessage) ID() MessageID

func (HaveMessage) Read added in v0.4.5

func (m HaveMessage) Read(b []byte) (int, error)

type HaveNoneMessage

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

func (HaveNoneMessage) ID

func (m HaveNoneMessage) ID() MessageID

func (HaveNoneMessage) Read added in v0.4.5

func (m HaveNoneMessage) Read(b []byte) (int, error)

type InterestedMessage

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

func (InterestedMessage) ID

func (InterestedMessage) Read added in v0.4.5

func (m InterestedMessage) Read(b []byte) (int, error)

type Message

type Message interface {
	io.Reader
	ID() MessageID
}

type MessageID

type MessageID uint8

MessageID is identifier for messages sent between peers.

func (MessageID) String

func (m MessageID) String() string

type NotInterestedMessage

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

func (NotInterestedMessage) ID

func (NotInterestedMessage) Read added in v0.4.5

func (m NotInterestedMessage) Read(b []byte) (int, error)

type PieceMessage

type PieceMessage struct {
	Index, Begin uint32
}

func (PieceMessage) ID

func (m PieceMessage) ID() MessageID

func (PieceMessage) Read added in v0.4.5

func (m PieceMessage) Read(b []byte) (int, error)

type PortMessage added in v0.8.4

type PortMessage struct {
	Port uint16
}

func (PortMessage) ID added in v0.8.4

func (m PortMessage) ID() MessageID

func (PortMessage) Read added in v0.8.4

func (m PortMessage) Read(b []byte) (n int, err error)

type RejectMessage

type RejectMessage struct{ RequestMessage }

func (RejectMessage) ID

func (m RejectMessage) ID() MessageID

type RequestMessage

type RequestMessage struct {
	Index, Begin, Length uint32
}

func (RequestMessage) ID

func (m RequestMessage) ID() MessageID

func (RequestMessage) Read added in v0.4.5

func (m RequestMessage) Read(b []byte) (int, error)

type UnchokeMessage

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

func (UnchokeMessage) ID

func (m UnchokeMessage) ID() MessageID

func (UnchokeMessage) Read added in v0.4.5

func (m UnchokeMessage) Read(b []byte) (int, error)

Jump to

Keyboard shortcuts

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