tracker

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnounceReq

type AnnounceReq struct {
	InfoHash   [20]byte
	PeerID     [20]byte
	Downloaded int64
	Left       int64
	Uploaded   int64
	Event      Event
	IP         int32
	Key        int32
	Numwant    int32
	Port       int16
}

type AnnounceResp

type AnnounceResp struct {
	Interval int32
	Leechers int32
	Seeders  int32
	Peers    []Peer
	//if udp tracker then always zero.
	MinInterval int32
}

type Event

type Event int32
const (
	None Event = iota
	Completed
	Started
	Stopped
)

type HTTPTrackerURL

type HTTPTrackerURL struct {
	// contains filtered or unexported fields
}

func (*HTTPTrackerURL) Announce

func (t *HTTPTrackerURL) Announce(ctx context.Context, r AnnounceReq) (*AnnounceResp, error)

func (*HTTPTrackerURL) Scrape

func (t *HTTPTrackerURL) Scrape(ctx context.Context, infos ...[20]byte) (*ScrapeResp, error)

type Peer

type Peer struct {
	//Random ID generated by the peer
	ID   []byte `bencode:"peer id"`
	IP   net.IP `bencode:"ip"`
	Port uint16 `bencode:"port"`
}

func (*Peer) String

func (p *Peer) String() string

type ScrapeResp

type ScrapeResp struct {
	Torrents map[string]TorrentInfo
}

type TorrentInfo

type TorrentInfo struct {
	Seeders    int32  `bencode:"complete"`
	Downloaded int32  `bencode:"downloaded"`
	Leechers   int32  `bencode:"incomplete"`
	Name       string `bencode:"name" empty:"omit"`
}

type TrackerURL

type TrackerURL interface {
	Announce(context.Context, AnnounceReq) (*AnnounceResp, error)
	Scrape(context.Context, ...[20]byte) (*ScrapeResp, error)
}

func NewTrackerURL

func NewTrackerURL(tURL string) (TrackerURL, error)

type UDPTrackerURL

type UDPTrackerURL struct {
	// contains filtered or unexported fields
}

func (*UDPTrackerURL) Announce

func (t *UDPTrackerURL) Announce(ctx context.Context, r AnnounceReq) (*AnnounceResp, error)

func (*UDPTrackerURL) Scrape

func (t *UDPTrackerURL) Scrape(ctx context.Context, ihashes ...[20]byte) (*ScrapeResp, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL