tracker

package
v0.0.0-...-befd6c4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2015 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package tracker provides a generic interface for manipulating a BitTorrent tracker's fast-moving data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server interface {
	// Serve runs the server and blocks until the server has shut down.
	Serve(addr string)

	// Stop cleanly shuts down the server in a non-blocking manner.
	Stop()
}

Server represents a server for a given BitTorrent tracker protocol.

type Storage

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

func NewStorage

func NewStorage(cfg *config.Config) *Storage

func (*Storage) ClientApproved

func (s *Storage) ClientApproved(peerID string) error

func (*Storage) DeleteClient

func (s *Storage) DeleteClient(peerID string)

func (*Storage) DeleteLeecher

func (s *Storage) DeleteLeecher(infohash string, p *models.Peer) error

func (*Storage) DeleteSeeder

func (s *Storage) DeleteSeeder(infohash string, p *models.Peer) error

func (*Storage) DeleteTorrent

func (s *Storage) DeleteTorrent(infohash string)

func (*Storage) DeleteUser

func (s *Storage) DeleteUser(passkey string)

func (*Storage) FindTorrent

func (s *Storage) FindTorrent(infohash string) (*models.Torrent, error)

func (*Storage) FindUser

func (s *Storage) FindUser(passkey string) (*models.User, error)

func (*Storage) IncrementTorrentSnatches

func (s *Storage) IncrementTorrentSnatches(infohash string) error

func (*Storage) Len

func (s *Storage) Len() int

func (*Storage) PurgeInactivePeers

func (s *Storage) PurgeInactivePeers(purgeEmptyTorrents bool, before time.Time) error

func (*Storage) PurgeInactiveTorrent

func (s *Storage) PurgeInactiveTorrent(infohash string) error

func (*Storage) PutClient

func (s *Storage) PutClient(peerID string)

func (*Storage) PutLeecher

func (s *Storage) PutLeecher(infohash string, p *models.Peer) error

func (*Storage) PutSeeder

func (s *Storage) PutSeeder(infohash string, p *models.Peer) error

func (*Storage) PutTorrent

func (s *Storage) PutTorrent(torrent *models.Torrent)

func (*Storage) PutUser

func (s *Storage) PutUser(user *models.User)

func (*Storage) TouchTorrent

func (s *Storage) TouchTorrent(infohash string) error

type Torrents

type Torrents struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type Tracker

type Tracker struct {
	Config  *config.Config
	Backend backend.Conn
	*Storage
}

Tracker represents the logic necessary to service BitTorrent announces, independently of the underlying data transports used.

func New

func New(cfg *config.Config) (*Tracker, error)

New creates a new Tracker, and opens any necessary connections. Maintenance routines are automatically spawned in the background.

func (*Tracker) Close

func (tkr *Tracker) Close() error

Close gracefully shutdowns a Tracker by closing any database connections.

func (*Tracker) HandleAnnounce

func (tkr *Tracker) HandleAnnounce(ann *models.Announce, w Writer) (err error)

HandleAnnounce encapsulates all of the logic of handling a BitTorrent client's Announce without being coupled to any transport protocol.

func (*Tracker) HandleScrape

func (tkr *Tracker) HandleScrape(scrape *models.Scrape, w Writer) (err error)

HandleScrape encapsulates all the logic of handling a BitTorrent client's scrape without being coupled to any transport protocol.

func (*Tracker) LoadApprovedClients

func (tkr *Tracker) LoadApprovedClients(clients []string)

LoadApprovedClients loads a list of client IDs into the tracker's storage.

type Writer

type Writer interface {
	WriteError(err error) error
	WriteAnnounce(*models.AnnounceResponse) error
	WriteScrape(*models.ScrapeResponse) error
}

Writer serializes a tracker's responses, and is implemented for each response transport used by the tracker. Only one of these may be called per request, and only once.

Note, data passed into any of these functions will not contain sensitive information, so it may be passed back the client freely.

Directories

Path Synopsis
Package models implements the common data types used throughout a BitTorrent tracker.
Package models implements the common data types used throughout a BitTorrent tracker.

Jump to

Keyboard shortcuts

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