tracker

package
v0.0.0-...-c8d95c1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package tracker implements the HTTP and UDP BitTorrent tracker protocols, as defined in BEP-3, BEP-7, BEP-23 and BEP-15.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotReady = errors.New("tracker not ready")
	ErrParse    = errors.New("couldn't parse tracker reply")
)

Functions

This section is empty.

Types

type HTTP

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

HTTP represents a tracker accessed over HTTP or HTTPS.

func (*HTTP) Announce

func (tracker *HTTP) Announce(ctx context.Context, hash []byte, myid []byte,
	want int, size int64, port4, port6 int, proxy string,
	f func(net.IP, int) bool) error

Announce performs an HTTP announce over both IPv4 and IPv6 in parallel.

func (*HTTP) GetState

func (tracker *HTTP) GetState() (State, error)

GetState returns a tracker's state.

func (*HTTP) URL

func (tracker *HTTP) URL() string

type State

type State int

Type State represtents the state of a tracker.

const (
	Disabled State = -3 // the tracker is disabled
	Error    State = -2 // last request failed
	Busy     State = -1 // a request is in progress
	Idle     State = 0  // it's not time yet for a new request
	Ready    State = 1  // a request may be scheduled now
)

func (State) String

func (state State) String() string

type Tracker

type Tracker interface {
	// URL returns the tracker URL
	URL() string
	// GetState returns the tracker's state.  If the state is Error,
	// then GetState also returns an error value.
	GetState() (State, error)
	// Announce performs parallel announces over both IPv4 and IPv6.
	Announce(ctx context.Context, hash []byte, myid []byte,
		want int, size int64, port4, port6 int, proxy string,
		f func(net.IP, int) bool) error
}

Type Tracker represents a BitTorrent tracker.

func New

func New(url string) Tracker

New creates a new tracker from a URL.

type UDP

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

UDP represents a tracker using the protocol defined in BEP-15.

func (*UDP) Announce

func (tracker *UDP) Announce(ctx context.Context, hash []byte, myid []byte,
	want int, size int64, port4, port6 int, proxy string,
	f func(net.IP, int) bool) error

Announce performs a UDP announce over IPv4 and Ipv6 in parallel.

func (*UDP) GetState

func (tracker *UDP) GetState() (State, error)

GetState returns a tracker's state.

func (*UDP) URL

func (tracker *UDP) URL() string

type Unknown

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

Unknown represents a tracker with an unknown scheme.

func (*Unknown) Announce

func (tracker *Unknown) Announce(ctx context.Context, hash []byte, myid []byte,
	want int, size int64, port4, port6 int, proxy string,
	f func(net.IP, int) bool) error

Announce performs parallel announces over both IPv4 and IPv6.

func (*Unknown) GetState

func (tracker *Unknown) GetState() (State, error)

GetState for an tracker with an unknown scheme always returns Disabled.

func (*Unknown) URL

func (tracker *Unknown) URL() string

Jump to

Keyboard shortcuts

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