Documentation ¶
Overview ¶
Package protocol implements low-level details of the BitTorrent protocol.
Index ¶
- Constants
- Variables
- func GetBuffer(length int) []byte
- func PutBuffer(buf []byte)
- func Reader(c net.Conn, init []byte, l *log.Logger, ch chan<- Message, ...)
- func Write(w *bufio.Writer, m Message, l *log.Logger) error
- func Writer(conn net.Conn, l *log.Logger, ch <-chan Message, done chan<- struct{}) error
- type AllowedFast
- type Bitfield
- type Cancel
- type Choke
- type Error
- type Extended0
- type ExtendedDontHave
- type ExtendedMetadata
- type ExtendedPex
- type ExtendedUnknown
- type ExtendedUploadOnly
- type Flush
- type HandshakeResult
- func ClientHandshake(c net.Conn, cryptoHandshake bool, infoHash hash.Hash, myid hash.Hash, ...) (conn net.Conn, result HandshakeResult, init []byte, err error)
- func ServerHandshake(c net.Conn, hashes []hash.HashPair, cryptoOptions *crypto.Options) (conn net.Conn, result HandshakeResult, init []byte, err error)
- type Have
- type HaveAll
- type HaveNone
- type Interested
- type KeepAlive
- type Message
- type NotInterested
- type Piece
- type Port
- type RejectRequest
- type Request
- type SuggestPiece
- type Unchoke
- type Unknown
Constants ¶
View Source
const ( ExtPex uint8 = 1 ExtMetadata uint8 = 2 ExtDontHave uint8 = 3 ExtUploadOnly uint8 = 4 )
The subtypes we negotiate for reception of extended messages. We send the subtypes requested by the peer, as required by the extension mechanism.
Variables ¶
View Source
var ErrBadHandshake = errors.New("bad handshake")
View Source
var ErrParse = errors.New("parse error")
View Source
var ErrUnknownTorrent = errors.New("unknown torrent")
Functions ¶
func PutBuffer ¶
func PutBuffer(buf []byte)
PutBuffer releases a buffer obtained by GetBuffer. The buffer must not be used again.
func Reader ¶
Reader reads BitTorrent messages from c until it is closed. The parameter init contains data that is prepended to the data received from c. If l is not nil, then all messages read are logged.
Types ¶
type AllowedFast ¶
type AllowedFast struct {
Index uint32
}
type ExtendedDontHave ¶
type ExtendedMetadata ¶
type ExtendedUnknown ¶
type ExtendedUnknown struct {
Subtype uint8
}
type ExtendedUploadOnly ¶
type HandshakeResult ¶
type HandshakeResult struct { // the torrent hash Hash hash.Hash // the peer's id Id hash.Hash // supported extensions Dht, Fast, Extended bool }
HandshakeResult is the result of a BitTorrent handshake
type Interested ¶
type Interested struct{}
type NotInterested ¶
type NotInterested struct{}
type RejectRequest ¶
type RejectRequest struct {
Index, Begin, Length uint32
}
type SuggestPiece ¶
type SuggestPiece struct {
Index uint32
}
Click to show internal directories.
Click to hide internal directories.