tracker

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tracker provides support for announcing torrents to HTTP and UDP trackers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePeersCompact

func DecodePeersCompact(b []byte) ([]*net.TCPAddr, error)

func ResolveHost

func ResolveHost(ctx context.Context, addr string, bl *blocklist.Blocklist) (net.IP, int, error)

Types

type AnnounceRequest

type AnnounceRequest struct {
	Torrent Torrent
	Event   Event
	NumWant int
}

type AnnounceResponse

type AnnounceResponse struct {
	Error       error
	Interval    time.Duration
	MinInterval time.Duration
	Leechers    int32
	Seeders     int32
	Peers       []*net.TCPAddr
}

type CompactPeer

type CompactPeer struct {
	IP   [net.IPv4len]byte
	Port uint16
}

func NewCompactPeer

func NewCompactPeer(addr *net.TCPAddr) CompactPeer

func (CompactPeer) Addr

func (p CompactPeer) Addr() *net.TCPAddr

func (CompactPeer) MarshalBinary

func (p CompactPeer) MarshalBinary() ([]byte, error)

func (*CompactPeer) UnmarshalBinary

func (p *CompactPeer) UnmarshalBinary(data []byte) error

type Error

type Error string

Error is the string that is sent by the tracker from announce or scrape.

func (Error) Error

func (e Error) Error() string

type Event

type Event int32
const (
	EventNone Event = iota
	EventCompleted
	EventStarted
	EventStopped
)

Tracker Announce Events. Numbers corresponds to constants in UDP tracker protocol.

func (Event) String

func (e Event) String() string

String returns the name of event as represented in HTTP tracker protocol.

type Torrent

type Torrent struct {
	BytesUploaded   int64
	BytesDownloaded int64
	BytesLeft       int64
	InfoHash        [20]byte
	PeerID          [20]byte
	Port            int
}

type Tracker

type Tracker interface {
	// Announce transfer to the tracker.
	// Announce should be called periodically with the interval returned in AnnounceResponse.
	// Announce should also be called on specific events.
	Announce(ctx context.Context, req AnnounceRequest) (*AnnounceResponse, error)

	// URL of the tracker.
	URL() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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