trackerServer

package
v1.51.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MPL-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnounceAddr

type AnnounceAddr = netip.AddrPort

type AnnounceHandler

type AnnounceHandler struct {
	AnnounceTracker AnnounceTracker

	UpstreamTrackers       []Client
	UpstreamTrackerUrls    []string
	UpstreamAnnouncePeerId [20]byte
	UpstreamAnnounceGate   UpstreamAnnounceGater
	// contains filtered or unexported fields
}

func (*AnnounceHandler) Serve

type AnnounceRequest

type AnnounceRequest = tracker.AnnounceRequest

type AnnounceTracker

type AnnounceTracker interface {
	TrackAnnounce(ctx context.Context, req udp.AnnounceRequest, addr AnnounceAddr) error
	Scrape(ctx context.Context, infoHashes []InfoHash) ([]udp.ScrapeInfohashResult, error)
	GetPeers(
		ctx context.Context,
		infoHash InfoHash,
		opts GetPeersOpts,
		remote AnnounceAddr,
	) ServerAnnounceResult
}

type Client

type Client = tracker.Client

type GetPeersOpts

type GetPeersOpts struct {
	// Negative numbers are not allowed.
	MaxCount generics.Option[uint]
}

This is reserved for stuff like filtering by IP version, avoiding an announcer's IP or key, limiting return count, etc.

type InfoHash

type InfoHash = [20]byte

type Peer

type Peer = tracker.Peer

type PeerInfo

type PeerInfo struct {
	AnnounceAddr
}

type ServerAnnounceResult

type ServerAnnounceResult struct {
	Err      error
	Peers    []PeerInfo
	Interval generics.Option[int32]
	Leechers generics.Option[int32]
	Seeders  generics.Option[int32]
}

type UpstreamAnnounceGater

type UpstreamAnnounceGater interface {
	Start(ctx context.Context, tracker string, infoHash InfoHash,

		timeout time.Duration,
	) (bool, error)
	Completed(
		ctx context.Context, tracker string, infoHash InfoHash,

		interval int32,
	) error
}

Jump to

Keyboard shortcuts

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