peerprotocol

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 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
}

func (BitfieldMessage) ID

func (m BitfieldMessage) ID() MessageID

func (BitfieldMessage) MarshalBinary

func (m BitfieldMessage) MarshalBinary() ([]byte, 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) MarshalBinary

func (m ChokeMessage) MarshalBinary() ([]byte, error)

type ExtensionHandshakeMessage

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

func NewExtensionHandshake

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

type ExtensionMessage

type ExtensionMessage struct {
	ExtendedMessageID uint8
	Payload           interface{}
}

func (ExtensionMessage) ID

func (m ExtensionMessage) ID() MessageID

func (ExtensionMessage) MarshalBinary

func (m ExtensionMessage) MarshalBinary() ([]byte, error)

func (*ExtensionMessage) UnmarshalBinary

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

type ExtensionMetadataMessage

type ExtensionMetadataMessage struct {
	Type      uint32 `bencode:"msg_type"`
	Piece     uint32 `bencode:"piece"`
	TotalSize uint32 `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) MarshalBinary

func (m HaveAllMessage) MarshalBinary() ([]byte, error)

type HaveMessage

type HaveMessage struct {
	Index uint32
}

func (HaveMessage) ID

func (m HaveMessage) ID() MessageID

func (HaveMessage) MarshalBinary

func (m HaveMessage) MarshalBinary() ([]byte, error)

type HaveNoneMessage

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

func (HaveNoneMessage) ID

func (m HaveNoneMessage) ID() MessageID

func (HaveNoneMessage) MarshalBinary

func (m HaveNoneMessage) MarshalBinary() ([]byte, error)

type InterestedMessage

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

func (InterestedMessage) ID

func (InterestedMessage) MarshalBinary

func (m InterestedMessage) MarshalBinary() ([]byte, error)

type Message

type Message interface {
	encoding.BinaryMarshaler
	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) MarshalBinary

func (m NotInterestedMessage) MarshalBinary() ([]byte, error)

type PieceMessage

type PieceMessage struct {
	Index, Begin uint32
}

func (PieceMessage) ID

func (m PieceMessage) ID() MessageID

func (PieceMessage) MarshalBinary

func (m PieceMessage) MarshalBinary() ([]byte, 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) MarshalBinary

func (m RequestMessage) MarshalBinary() ([]byte, error)

type UnchokeMessage

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

func (UnchokeMessage) ID

func (m UnchokeMessage) ID() MessageID

func (UnchokeMessage) MarshalBinary

func (m UnchokeMessage) MarshalBinary() ([]byte, error)

Jump to

Keyboard shortcuts

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