Documentation
¶
Index ¶
- Constants
- Variables
- func Debugf(format string, v ...interface{})
- func WrapError(msg string, err error) error
- type AnnounceRequest
- type AnnounceResponse
- type Announcer
- type ErrorResponse
- type Event
- type InfoHash
- type OptionalAnnounceResponse
- type OptionalScrapeResponse
- type Peer
- type Scrape
- type ScrapeRequest
- type ScrapeResponse
- type Scraper
- type WarningResponse
Constants ¶
const ( EventStarted = iota EventStopped EventCompleted EventNone EventInvalid = 9 )
Events for announces.
Variables ¶
var Debug bool
Debug enables debug logging.
Functions ¶
Types ¶
type AnnounceRequest ¶
type AnnounceRequest struct {
InfoHash InfoHash
Uploaded int
Downloaded int
Left int
Compact bool
Event Event
Numwant int
Peer
}
AnnounceRequest represents an announce request.
type AnnounceResponse ¶
type AnnounceResponse struct {
Interval int
MinInterval int
Complete int
Incomplete int
Peers []Peer
}
AnnounceResponse represents an announce response.
type Announcer ¶
type Announcer interface {
Announce(AnnounceRequest) (OptionalAnnounceResponse, error)
}
Announcer provides the Announce method.
type InfoHash ¶
type InfoHash []byte
InfoHash represents a 20-byte infohash in hexadecimal format.
func NewInfohash ¶
NewInfohash generates a unique, random InfoHash.
type OptionalAnnounceResponse ¶
type OptionalAnnounceResponse interface {
// contains filtered or unexported methods
}
OptionalAnnounceResponse is a marker interface for all types that could be returned for an announce request. It is implemented by AnnounceResponse, ErrorResponse and WarningResponse.
type OptionalScrapeResponse ¶
type OptionalScrapeResponse interface {
// contains filtered or unexported methods
}
OptionalScrapeResponse is a marker interface for all types that could be returned for a scrape request. It is implemented by ScrapeResponse and ErrorResponse.
type Peer ¶
Peer represents a peer in a BitTorrent swarm.
func NewPeer ¶
NewPeer generates a random, unique Peer. The peer will have its ID prefixed by peerPrefix.
func (Peer) IsEqual ¶
IsEqual compares the peer to another peer and returns true if their ports are equal.
This works for Peers generated by Poke because they are guaranteed to have unique ports.
func (Peer) IsReallyEqual ¶
IsReallyEqual compares the peer to another peer and returns true if they are equal.
type ScrapeRequest ¶
type ScrapeRequest struct {
InfoHashes []InfoHash
}
ScrapeRequest respresents a scrape request.
type ScrapeResponse ¶
type ScrapeResponse struct {
Files []Scrape
}
ScrapeResponse represents a scrape response.
type Scraper ¶
type Scraper interface {
Scrape(ScrapeRequest) (OptionalScrapeResponse, error)
}
Scraper provides the Scrape method.
type WarningResponse ¶
type WarningResponse string
WarningResponse represents a tracker warning response.