p2p

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package p2p is a generated protocol buffer package.

It is generated from these files:

proto/p2p/p2p.proto

It has these top-level messages:

BitfieldMessage
PieceRequestMessage
PiecePayloadMessage
AnnouncePieceMessage
CancelPieceMessage
ErrorMessage
CompleteMessage
Message

Index

Constants

This section is empty.

Variables

View Source
var ErrorMessage_ErrorCode_name = map[int32]string{
	0: "PIECE_REQUEST_FAILED",
}
View Source
var ErrorMessage_ErrorCode_value = map[string]int32{
	"PIECE_REQUEST_FAILED": 0,
}
View Source
var Message_Type_name = map[int32]string{
	0: "BITFIELD",
	1: "PIECE_REQUEST",
	2: "PIECE_PAYLOAD",
	3: "ANNOUCE_PIECE",
	4: "CANCEL_PIECE",
	5: "ERROR",
	6: "COMPLETE",
}
View Source
var Message_Type_value = map[string]int32{
	"BITFIELD":      0,
	"PIECE_REQUEST": 1,
	"PIECE_PAYLOAD": 2,
	"ANNOUCE_PIECE": 3,
	"CANCEL_PIECE":  4,
	"ERROR":         5,
	"COMPLETE":      6,
}

Functions

This section is empty.

Types

type AnnouncePieceMessage

type AnnouncePieceMessage struct {
	Index int32 `protobuf:"varint,2,opt,name=index" json:"index,omitempty"`
}

Announces that a piece is available to other peers.

func (*AnnouncePieceMessage) Descriptor

func (*AnnouncePieceMessage) Descriptor() ([]byte, []int)

func (*AnnouncePieceMessage) ProtoMessage

func (*AnnouncePieceMessage) ProtoMessage()

func (*AnnouncePieceMessage) Reset

func (m *AnnouncePieceMessage) Reset()

func (*AnnouncePieceMessage) String

func (m *AnnouncePieceMessage) String() string

type BitfieldMessage

type BitfieldMessage struct {
	InfoHash string `protobuf:"bytes,2,opt,name=infoHash" json:"infoHash,omitempty"`
	// TODO: Torrent name is the content hash. Current torrent storage is
	// content addressable. Adding name as a part of handshake makes looking
	// up torrents faster. If storage supports addressing torrent by infohash,
	// this extra field should removed.
	// XXX(codyg): We rely on this name field for announcing too, so tracker can
	// look up origins that have this content.
	// We currently treat infohash as verification of torrents.
	Name          string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
	PeerID        string `protobuf:"bytes,4,opt,name=peerID" json:"peerID,omitempty"`
	BitfieldBytes []byte `protobuf:"bytes,5,opt,name=bitfieldBytes,proto3" json:"bitfieldBytes,omitempty"`
	Namespace     string `protobuf:"bytes,6,opt,name=namespace" json:"namespace,omitempty"`
	// remoteBitfieldBytes contains the binary sets of pieces downloaded of
	// all peers that the sender is currently connected to.
	RemoteBitfieldBytes map[string][]byte `` /* 165-byte string literal not displayed */
}

Binary set of all pieces that peer has downloaded so far. Also serves as a handshaking message, which each peer sends once at the beginning of the connection to declare what their peer id is and what info hash they want to transmit.

func (*BitfieldMessage) Descriptor

func (*BitfieldMessage) Descriptor() ([]byte, []int)

func (*BitfieldMessage) GetRemoteBitfieldBytes

func (m *BitfieldMessage) GetRemoteBitfieldBytes() map[string][]byte

func (*BitfieldMessage) ProtoMessage

func (*BitfieldMessage) ProtoMessage()

func (*BitfieldMessage) Reset

func (m *BitfieldMessage) Reset()

func (*BitfieldMessage) String

func (m *BitfieldMessage) String() string

type CancelPieceMessage

type CancelPieceMessage struct {
	Index int32 `protobuf:"varint,2,opt,name=index" json:"index,omitempty"`
}

Unused.

func (*CancelPieceMessage) Descriptor

func (*CancelPieceMessage) Descriptor() ([]byte, []int)

func (*CancelPieceMessage) ProtoMessage

func (*CancelPieceMessage) ProtoMessage()

func (*CancelPieceMessage) Reset

func (m *CancelPieceMessage) Reset()

func (*CancelPieceMessage) String

func (m *CancelPieceMessage) String() string

type CompleteMessage

type CompleteMessage struct {
}

Notifies other peers that the torrent has completed and all pieces are available.

func (*CompleteMessage) Descriptor

func (*CompleteMessage) Descriptor() ([]byte, []int)

func (*CompleteMessage) ProtoMessage

func (*CompleteMessage) ProtoMessage()

func (*CompleteMessage) Reset

func (m *CompleteMessage) Reset()

func (*CompleteMessage) String

func (m *CompleteMessage) String() string

type ErrorMessage

type ErrorMessage struct {
	Error string                 `protobuf:"bytes,2,opt,name=error" json:"error,omitempty"`
	Index int32                  `protobuf:"varint,3,opt,name=index" json:"index,omitempty"`
	Code  ErrorMessage_ErrorCode `protobuf:"varint,4,opt,name=code,enum=p2p.ErrorMessage_ErrorCode" json:"code,omitempty"`
}

General purpose error message. Receivers may check the error code to determine the origin of the message.

func (*ErrorMessage) Descriptor

func (*ErrorMessage) Descriptor() ([]byte, []int)

func (*ErrorMessage) ProtoMessage

func (*ErrorMessage) ProtoMessage()

func (*ErrorMessage) Reset

func (m *ErrorMessage) Reset()

func (*ErrorMessage) String

func (m *ErrorMessage) String() string

type ErrorMessage_ErrorCode

type ErrorMessage_ErrorCode int32
const (
	ErrorMessage_PIECE_REQUEST_FAILED ErrorMessage_ErrorCode = 0
)

func (ErrorMessage_ErrorCode) EnumDescriptor

func (ErrorMessage_ErrorCode) EnumDescriptor() ([]byte, []int)

func (ErrorMessage_ErrorCode) String

func (x ErrorMessage_ErrorCode) String() string

type Message

type Message struct {
	Version       string                `protobuf:"bytes,1,opt,name=version" json:"version,omitempty"`
	Type          Message_Type          `protobuf:"varint,2,opt,name=type,enum=p2p.Message_Type" json:"type,omitempty"`
	Bitfield      *BitfieldMessage      `protobuf:"bytes,3,opt,name=bitfield" json:"bitfield,omitempty"`
	PieceRequest  *PieceRequestMessage  `protobuf:"bytes,4,opt,name=pieceRequest" json:"pieceRequest,omitempty"`
	PiecePayload  *PiecePayloadMessage  `protobuf:"bytes,5,opt,name=piecePayload" json:"piecePayload,omitempty"`
	AnnouncePiece *AnnouncePieceMessage `protobuf:"bytes,6,opt,name=announcePiece" json:"announcePiece,omitempty"`
	CancelPiece   *CancelPieceMessage   `protobuf:"bytes,7,opt,name=cancelPiece" json:"cancelPiece,omitempty"`
	Error         *ErrorMessage         `protobuf:"bytes,8,opt,name=error" json:"error,omitempty"`
	Complete      *CompleteMessage      `protobuf:"bytes,9,opt,name=complete" json:"complete,omitempty"`
}

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) GetAnnouncePiece

func (m *Message) GetAnnouncePiece() *AnnouncePieceMessage

func (*Message) GetBitfield

func (m *Message) GetBitfield() *BitfieldMessage

func (*Message) GetCancelPiece

func (m *Message) GetCancelPiece() *CancelPieceMessage

func (*Message) GetComplete

func (m *Message) GetComplete() *CompleteMessage

func (*Message) GetError

func (m *Message) GetError() *ErrorMessage

func (*Message) GetPiecePayload

func (m *Message) GetPiecePayload() *PiecePayloadMessage

func (*Message) GetPieceRequest

func (m *Message) GetPieceRequest() *PieceRequestMessage

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

type Message_Type

type Message_Type int32
const (
	Message_BITFIELD      Message_Type = 0
	Message_PIECE_REQUEST Message_Type = 1
	Message_PIECE_PAYLOAD Message_Type = 2
	Message_ANNOUCE_PIECE Message_Type = 3
	Message_CANCEL_PIECE  Message_Type = 4
	Message_ERROR         Message_Type = 5
	Message_COMPLETE      Message_Type = 6
)

func (Message_Type) EnumDescriptor

func (Message_Type) EnumDescriptor() ([]byte, []int)

func (Message_Type) String

func (x Message_Type) String() string

type PiecePayloadMessage

type PiecePayloadMessage struct {
	Index  int32  `protobuf:"varint,2,opt,name=index" json:"index,omitempty"`
	Offset int32  `protobuf:"varint,3,opt,name=offset" json:"offset,omitempty"`
	Length int32  `protobuf:"varint,4,opt,name=length" json:"length,omitempty"`
	Digest string `protobuf:"bytes,5,opt,name=digest" json:"digest,omitempty"`
}

Provides binary payload response to a peer request. Always immediately followed by a binary blob sent over socket, so the receiver should be ready to treat the blob as a non-protobuf message.

func (*PiecePayloadMessage) Descriptor

func (*PiecePayloadMessage) Descriptor() ([]byte, []int)

func (*PiecePayloadMessage) ProtoMessage

func (*PiecePayloadMessage) ProtoMessage()

func (*PiecePayloadMessage) Reset

func (m *PiecePayloadMessage) Reset()

func (*PiecePayloadMessage) String

func (m *PiecePayloadMessage) String() string

type PieceRequestMessage

type PieceRequestMessage struct {
	Index  int32 `protobuf:"varint,2,opt,name=index" json:"index,omitempty"`
	Offset int32 `protobuf:"varint,3,opt,name=offset" json:"offset,omitempty"`
	Length int32 `protobuf:"varint,4,opt,name=length" json:"length,omitempty"`
}

Requests a piece of the given index. Note: offset and length are unused fields and if set, will be rejected.

func (*PieceRequestMessage) Descriptor

func (*PieceRequestMessage) Descriptor() ([]byte, []int)

func (*PieceRequestMessage) ProtoMessage

func (*PieceRequestMessage) ProtoMessage()

func (*PieceRequestMessage) Reset

func (m *PieceRequestMessage) Reset()

func (*PieceRequestMessage) String

func (m *PieceRequestMessage) String() string

Jump to

Keyboard shortcuts

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