tracker

package
v0.0.0-...-930363b Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMissingInfoHash = errorsx.String("missing info hash")
)

Variables

View Source
var (
	ErrBadScheme = errors.New("unknown scheme")
)

Functions

func AnnounceOptionEventCompleted

func AnnounceOptionEventCompleted(ar *AnnounceRequest)

func AnnounceOptionEventStarted

func AnnounceOptionEventStarted(ar *AnnounceRequest)

func AnnounceOptionEventStopped

func AnnounceOptionEventStopped(ar *AnnounceRequest)

func AnnounceOptionKey

func AnnounceOptionKey(ar *AnnounceRequest)

func AnnounceOptionSeeding

func AnnounceOptionSeeding(ar *AnnounceRequest)

Types

type Action

type Action int32
const (
	ActionConnect Action = iota
	ActionAnnounce
	ActionScrape
	ActionError
)

type Announce

type Announce struct {
	TrackerUrl string
	// UdpNetwork string
	UserAgent string
	// If the port is zero, it's assumed to be the same as the Request.Port.
	ClientIp4 krpc.NodeAddr
	// If the port is zero, it's assumed to be the same as the Request.Port.
	ClientIp6 krpc.NodeAddr
	Dialer    netx.Dialer
}

func (Announce) Do

func (me Announce) Do(ctx context.Context, req AnnounceRequest) (res AnnounceResponse, err error)

func (Announce) ForTracker

func (me Announce) ForTracker(uri string) Announce

type AnnounceEvent

type AnnounceEvent int32
const (
	None      AnnounceEvent = iota
	Completed               // The local peer just completed the torrent.
	Started                 // The local peer has just resumed this torrent.
	Stopped                 // The local peer is leaving the swarm.
)

func (AnnounceEvent) String

func (e AnnounceEvent) String() string

type AnnounceOption

type AnnounceOption func(*AnnounceRequest)

func AnnounceOptionDownloaded

func AnnounceOptionDownloaded(n int64) AnnounceOption

func AnnounceOptionRemaining

func AnnounceOptionRemaining(n int64) AnnounceOption

func AnnounceOptionUploaded

func AnnounceOptionUploaded(n int64) AnnounceOption

type AnnounceRequest

type AnnounceRequest struct {
	InfoHash   [20]byte
	PeerId     [20]byte
	Downloaded int64
	Left       int64 // math.MaxInt64 will be used by default
	Uploaded   int64
	// Apparently this is optional. None can be used for announces done at
	// regular intervals.
	Event     AnnounceEvent
	IPAddress uint32
	Key       int32
	NumWant   int32 // How many peer addresses are desired. -1 for default.
	Port