tracker

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

* bittorrent announce via tracker

Index

Constants

View Source
const Completed = Event("completed")
View Source
const Nop = Event("")
View Source
const Started = Event("started")
View Source
const Stopped = Event("stopped")

Variables

This section is empty.

Functions

This section is empty.

Types

type Announcer

type Announcer interface {
	// announce and get peers
	Announce(req *Request) (*Response, error)
	// name of this tracker
	Name() string
}

bittorrent announcer, gets peers and announces presence in swarm

func FromURL

func FromURL(str string) Announcer

get announcer from url returns nil if invalid url

type Event

type Event string

func (Event) String

func (ev Event) String() string

type HttpTracker

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

http tracker

func NewHttpTracker

func NewHttpTracker(u *url.URL) *HttpTracker

create new http tracker from url

func (*HttpTracker) Announce

func (t *HttpTracker) Announce(req *Request) (resp *Response, err error)

send announce via http request

func (*HttpTracker) Name

func (t *HttpTracker) Name() string

type Request

type Request struct {
	Infohash   common.Infohash
	PeerID     common.PeerID
	Port       int
	Uploaded   uint64
	Downloaded uint64
	Left       uint64
	Event      Event
	NumWant    int
	Compact    bool
	GetNetwork func() network.Network
}

type Response

type Response struct {
	Interval     int           `bencode:"interval"`
	Peers        []common.Peer `bencode:"peers"`
	Error        string        `bencode:"failure reason"`
	NextAnnounce time.Time     `bencode:"-"`
}

Jump to

Keyboard shortcuts

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