Documentation ¶
Index ¶
Constants ¶
const ( EventNone event = 0 EventCompleted event = 1 EventStarted event = 2 EventStopped event = 3 ActionConnect Action = 0 ActionAnnounce Action = 1 ActionScrape Action = 2 ActionError Action = 3 ActionHeartbeat Action = 4 )
const (
UDPTrackerMagic = 0x41727101980
)
Variables ¶
var ( HeartbeatRequest = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, byte(ActionHeartbeat), 0, 0, 0, 0} HeartbeatOk = []byte{0xFF} )
Functions ¶
This section is empty.
Types ¶
type Announce ¶
type Announce struct { ConnectionID int64 Action Action TransactionID int32 InfoHash storage.Hash PeerID storage.PeerID Downloaded int64 Left int64 Uploaded int64 Event event IP uint32 Key uint32 NumWant int32 Port uint16 }
BitTorrent UDP tracker announce
func (*Announce) Unmarshall ¶
Unmarshall decodes a byte slice into an Announce.
type AnnounceResp ¶
type AnnounceResp struct { Action Action TransactionID int32 Interval int32 Leechers int32 Seeders int32 Peers []byte }
BitTorrent UDP tracker announce response
func (*AnnounceResp) Marshall ¶
func (ar *AnnounceResp) Marshall() ([]byte, error)
Marshall encodes an AnnounceResp to a byte slice.
func (*AnnounceResp) Unmarshall ¶
func (ar *AnnounceResp) Unmarshall(data []byte) error
Unmarshall decodes a byte slice into an AnnounceResp.
type Connect ¶
BitTorrent UDP tracker connect
func (*Connect) Unmarshall ¶
Unmarshall decodes a byte slice into a Connect.
type ConnectResp ¶
BitTorrent UDP tracker connect response
func (*ConnectResp) Marshall ¶
func (cr *ConnectResp) Marshall() ([]byte, error)
Marshall encodes a ConnectResp to a byte slice.
func (*ConnectResp) Unmarshall ¶
func (cr *ConnectResp) Unmarshall(data []byte) error
Unmarshall decodes a byte slice into a ConnectResp.
type Error ¶
BitTorrent UDP tracker server error
func (*Error) Unmarshall ¶
Unmarshall decodes a byte slice into an Error.
type Scrape ¶
type Scrape struct { ConnectionID int64 Action Action TransactionID int32 InfoHashes []storage.Hash }
BitTorrent UDP tracker announce
func (*Scrape) Unmarshall ¶
Unmarshall decodes a byte slice into a Scrape.
type ScrapeInfo ¶
ScrapeInfo holds the information for each infohash in the scrape response
type ScrapeResp ¶
type ScrapeResp struct { Action Action TransactionID int32 Info []ScrapeInfo }
BitTorrent UDP tracker scrape response
func (*ScrapeResp) Marshall ¶
func (sr *ScrapeResp) Marshall() ([]byte, error)
Marshall encodes a ScrapeResp to a byte slice.