tracker

package
v0.0.0-...-d617ca5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventNone     = 0
	EventComplete = 1
	EventStart    = 2
	EventStop     = 3
)

announce event

Variables

View Source
var (
	ErrNoVaildTracker = errors.New("no vaild tracker")
)

Tracker error

Functions

This section is empty.

Types

type DownloadStatus

type DownloadStatus struct {
	Download int64
	Upload   int64
	Left     int64
}

DownloadStatus is the download status to announce tracker

type HTTPTracker

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

HTTPTracker is a tracker use HTTP

func NewHTTPTracker

func NewHTTPTracker(url string) *HTTPTracker

NewHTTPTracker create a http tracker by url

func (*HTTPTracker) Announce

func (t *HTTPTracker) Announce(hash meta.Hash, id []byte, ip net.IP, port int, event int, status *DownloadStatus) ([]string, error)

Announce is used for announce to http tracker

type Manager

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

Manager mange trackers of a task

func NewManager

func NewManager(trackers []string, id []byte, ip string, port int) *Manager

NewManager return a Manager instance

func (*Manager) Announce

func (m *Manager) Announce(hash meta.Hash, status *DownloadStatus) ([]string, error)

Announce request peers to tracker

func (*Manager) Finish

func (m *Manager) Finish(hash meta.Hash, status *DownloadStatus) ([]string, error)

Finish announce the tracker the task is complete

func (*Manager) GetWaitTime

func (m *Manager) GetWaitTime() time.Time

GetWaitTime return the time will wait for next announce

func (*Manager) Start

func (m *Manager) Start(hash meta.Hash, status *DownloadStatus) ([]string, error)

Start announce start to a vaild tracker and return peers

func (*Manager) Stop

func (m *Manager) Stop(hash meta.Hash, status *DownloadStatus) ([]string, error)

Stop tell tracker the task is stop

type Tracker

type Tracker interface {
	Announce(hash meta.Hash, id []byte, ip net.IP, port int, event int, status *DownloadStatus) ([]string, error)
	// contains filtered or unexported methods
}

Tracker is a tracker interface

func NewTracker

func NewTracker(t string) Tracker

NewTracker return a Tracker instance

type UDPTracker

type UDPTracker struct {
	url.URL

	RecvStatus chan DownloadStatus
	// contains filtered or unexported fields
}

UDPTracker is a tracker use UDP

func NewUDPTracker

func NewUDPTracker(rawurl string) *UDPTracker

NewUDPTracker is used for create a udp tracker

func (*UDPTracker) Announce

func (t *UDPTracker) Announce(hash meta.Hash, id []byte, ip net.IP, port int, event int, status *DownloadStatus) ([]string, error)

Announce is used to announce to tracker

Jump to

Keyboard shortcuts

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