Documentation ¶
Index ¶
- Constants
- type AllowedFastMessage
- type BitfieldMessage
- type CancelMessage
- type ChokeMessage
- type ExtensionHandshakeMessage
- type ExtensionMessage
- type ExtensionMetadataMessage
- type ExtensionPEXMessage
- type HaveAllMessage
- type HaveMessage
- type HaveNoneMessage
- type InterestedMessage
- type Message
- type MessageID
- type NotInterestedMessage
- type PieceMessage
- type PortMessage
- type RejectMessage
- type RequestMessage
- type UnchokeMessage
Constants ¶
const ( // ExtensionIDHandshake is ID for extension handshake message. ExtensionIDHandshake = iota // ExtensionIDMetadata is ID for metadata extension messages. ExtensionIDMetadata // ExtensionIDPEX is ID for PEX extension messages. ExtensionIDPEX )
const ( // ExtensionKeyMetadata is the key for the metadata extension. ExtensionKeyMetadata = "ut_metadata" // ExtensionKeyPEX is the key for the PEX extension. ExtensionKeyPEX = "ut_pex" )
const ( // ExtensionMetadataMessageTypeRequest is the id of metadata message when requesting a piece. ExtensionMetadataMessageTypeRequest = iota // ExtensionMetadataMessageTypeData is the id of metadata message when sending the piece data. ExtensionMetadataMessageTypeData // ExtensionMetadataMessageTypeReject is the id of metadata message when rejecting a piece. ExtensionMetadataMessageTypeReject )
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 }
AllowedFastMessage is sent to tell a peer that it can download pieces regardless of choking status.
type BitfieldMessage ¶
type BitfieldMessage struct { Data []byte // contains filtered or unexported fields }
BitfieldMessage sent after the peer handshake to exchange piece availability information between peers.
func (BitfieldMessage) ID ¶
func (m BitfieldMessage) ID() MessageID
ID returns the peer protocol message type.
type CancelMessage ¶
type CancelMessage struct{ RequestMessage }
CancelMessage is sent to peer to cancel previosly sent request.
func (CancelMessage) ID ¶
func (m CancelMessage) ID() MessageID
ID returns the peer protocol message type.
type ChokeMessage ¶
type ChokeMessage struct {
// contains filtered or unexported fields
}
ChokeMessage is sent to peer that it should not request pieces.
func (ChokeMessage) ID ¶
func (m ChokeMessage) ID() MessageID
ID returns the peer protocol message type.
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"` }
ExtensionHandshakeMessage contains the information to do the extension handshake.
func NewExtensionHandshake ¶
func NewExtensionHandshake(metadataSize uint32, version string, yourip net.IP, requestQueueLength int) ExtensionHandshakeMessage
NewExtensionHandshake returns a new ExtensionHandshakeMessage by filling the struct with given values.
type ExtensionMessage ¶
type ExtensionMessage struct { ExtendedMessageID uint8 Payload interface{} }
ExtensionMessage is extension to BitTorrent protocol.
func (ExtensionMessage) ID ¶
func (m ExtensionMessage) ID() MessageID
ID returns the type of a peer message.
func (ExtensionMessage) Read ¶ added in v0.4.5
func (m ExtensionMessage) Read([]byte) (int, error)
Read extension message bytes.
func (*ExtensionMessage) UnmarshalBinary ¶
func (m *ExtensionMessage) UnmarshalBinary(data []byte) error
UnmarshalBinary parses extension message.
type ExtensionMetadataMessage ¶
type ExtensionMetadataMessage struct { Type int `bencode:"msg_type"` Piece uint32 `bencode:"piece"` TotalSize int `bencode:"total_size,omitempty"` Data []byte `bencode:"-"` }
ExtensionMetadataMessage is the message for the Metadata extension.
type ExtensionPEXMessage ¶
type ExtensionPEXMessage struct { Added string `bencode:"added"` Dropped string `bencode:"dropped"` }
ExtensionPEXMessage is the message for the PEX extension.
type HaveAllMessage ¶
type HaveAllMessage struct {
// contains filtered or unexported fields
}
HaveAllMessage can be sent to peer to indicate that we are a seed for this torrent.
func (HaveAllMessage) ID ¶
func (m HaveAllMessage) ID() MessageID
ID returns the peer protocol message type.
type HaveMessage ¶
type HaveMessage struct {
Index uint32
}
HaveMessage indicates a peer has the piece with index.
func (HaveMessage) ID ¶
func (m HaveMessage) ID() MessageID
ID returns the peer protocol message type.
type HaveNoneMessage ¶
type HaveNoneMessage struct {
// contains filtered or unexported fields
}
HaveNoneMessage is sent to peer to tell that we don't have any pieces.
func (HaveNoneMessage) ID ¶
func (m HaveNoneMessage) ID() MessageID
ID returns the peer protocol message type.
type InterestedMessage ¶
type InterestedMessage struct {
// contains filtered or unexported fields
}
InterestedMessage is sent to peer that we want to request pieces if you unchoke us.
func (InterestedMessage) ID ¶
func (m InterestedMessage) ID() MessageID
ID returns the peer protocol message type.
type NotInterestedMessage ¶
type NotInterestedMessage struct {
// contains filtered or unexported fields
}
NotInterestedMessage is sent to peer that we don't want any peer from you.
func (NotInterestedMessage) ID ¶
func (m NotInterestedMessage) ID() MessageID
ID returns the peer protocol message type.
type PieceMessage ¶
type PieceMessage struct {
Index, Begin uint32
}
PieceMessage is sent when a peer wants to upload piece data.
func (PieceMessage) ID ¶
func (m PieceMessage) ID() MessageID
ID returns the peer protocol message type.
type PortMessage ¶ added in v0.8.0
type PortMessage struct {
Port uint16
}
PortMessage is sent to announce the UDP port number of DHT node run by the peer.
func (PortMessage) ID ¶ added in v0.8.0
func (m PortMessage) ID() MessageID
ID returns the peer protocol message type.
type RejectMessage ¶
type RejectMessage struct{ RequestMessage }
RejectMessage is sent to peer to tell that we are rejecting a request from you.
func (RejectMessage) ID ¶
func (m RejectMessage) ID() MessageID
ID returns the peer protocol message type.
type RequestMessage ¶
type RequestMessage struct {
Index, Begin, Length uint32
}
RequestMessage is sent when a peer needs a certain piece.
func (RequestMessage) ID ¶
func (m RequestMessage) ID() MessageID
ID returns the peer protocol message type.
type UnchokeMessage ¶
type UnchokeMessage struct {
// contains filtered or unexported fields
}
UnchokeMessage is sent to peer that it can request pieces.
func (UnchokeMessage) ID ¶
func (m UnchokeMessage) ID() MessageID
ID returns the peer protocol message type.