...

Package tracker

import "github.com/concurrency-8/tracker"
Overview
Index

Overview ▾

func GetMockAnnounceResponseBuf

func GetMockAnnounceResponseBuf(transactionID, interval, leechers, seeders uint32, peers []Peer) bytes.Buffer

GetMockAnnounceResponseBuf returns a test buffer with input transactionID, interval, leechers and seeders

func GetMockConnectResponseBuf

func GetMockConnectResponseBuf(transactionID uint32, connectionID uint64) bytes.Buffer

GetMockConnectResponseBuf returns a test buffer with the input transactionID and connectionID

func GetRandomTorrent

func GetRandomTorrent() parser.TorrentFile

type AnnounceResponse

AnnounceResponse is structure to hold details from announce request sent to tracker

type AnnounceResponse struct {
    Action        uint32
    TransactionID uint32
    Leechers      uint32
    Seeders       uint32
    Complete      uint   `bencode:"complete"`
    Downloaded    uint   `bencode:"downloaded"`
    Incomplete    uint   `bencode:"incomplete"`
    Interval      uint32 `bencode:"interval"`
    MinInterval   uint   `bencode:"min interval"`
    PeerBytes     []byte `bencode:"peers"`
    Peers         []Peer
}

func GetPeers

func GetPeers(u *url.URL, report *ClientStatusReport) (tr *AnnounceResponse, err error)

GetPeers returns the peer list given a valid udp/http announce url

type ClientStatusReport

ClientStatusReport is a structure storing current status for client and relevant information

type ClientStatusReport struct {
    Event       string
    TorrentFile parser.TorrentFile
    PeerID      string
    Port        uint16
    Uploaded    uint64
    Downloaded  uint64
    Left        uint64
    Data        []parser.Piece // This is for seeding
}

func GetClientStatusReport

func GetClientStatusReport(torrent parser.TorrentFile, port uint16) (report *ClientStatusReport)

GetClientStatusReport returns the initial report of client

func GetRandomClientReport

func GetRandomClientReport() (report *ClientStatusReport)

GetRandomClientReport gives a test ClientStatusReport object pointer.

type ConnectResponse

ConnectResponse is struture to hoild details from ConnectResponse

type ConnectResponse struct {
    Action        uint32
    TransactionID uint32
    ConnectionID  uint64
}

type Peer

Peer is a structure contains IP Address of a peer

type Peer struct {
    IPAdress uint32
    Port     uint16
}