Documentation ¶
Overview ¶
Package tracker provides a generic interface for manipulating a BitTorrent tracker's fast-moving data.
Index ¶
- type Storage
- func (s *Storage) ClientApproved(peerID string) error
- func (s *Storage) DeleteClient(peerID string)
- func (s *Storage) DeleteLeecher(infohash string, p *models.Peer) error
- func (s *Storage) DeleteSeeder(infohash string, p *models.Peer) error
- func (s *Storage) DeleteTorrent(infohash string)
- func (s *Storage) DeleteUser(passkey string)
- func (s *Storage) DumpTorrents() (t []*models.Torrent)
- func (s *Storage) FindTorrent(infohash string) (*models.Torrent, error)
- func (s *Storage) FindUser(passkey string) (*models.User, error)
- func (s *Storage) IncrementTorrentSnatches(infohash string) error
- func (s *Storage) Len() int
- func (s *Storage) PurgeInactivePeers(purgeEmptyTorrents bool, before time.Time) error
- func (s *Storage) PurgeInactiveTorrent(infohash string) error
- func (s *Storage) PutClient(peerID string)
- func (s *Storage) PutLeecher(infohash string, p *models.Peer) error
- func (s *Storage) PutSeeder(infohash string, p *models.Peer) error
- func (s *Storage) PutTorrent(torrent *models.Torrent)
- func (s *Storage) PutUser(user *models.User)
- func (s *Storage) TopTorrents(n int) (t []*models.Torrent)
- func (s *Storage) TouchTorrent(infohash string) error
- type Torrents
- type Tracker
- func (tkr *Tracker) ClientApproved(peerID string) (err error)
- func (tkr *Tracker) Close() error
- func (tkr *Tracker) DeleteLeecher(infohash string, p *models.Peer) (err error)
- func (tkr *Tracker) DeleteSeeder(infohash string, p *models.Peer) (err error)
- func (tkr *Tracker) DeleteTorrent(infohash string) error
- func (tkr *Tracker) DeleteUser(passkey string) (err error)
- func (tkr *Tracker) FindTorrent(infohash string) (t *models.Torrent, err error)
- func (tkr *Tracker) FindUser(passkey string) (u *models.User, err error)
- func (tkr *Tracker) HandleAnnounce(ann *models.Announce, w Writer) (err error)
- func (tkr *Tracker) HandleScrape(scrape *models.Scrape, w Writer) (err error)
- func (tkr *Tracker) IncrementTorrentSnatches(infohash string) (err error)
- func (tkr *Tracker) LoadApprovedClients(clients []string)
- func (tkr *Tracker) PurgeInactiveTorrent(infohash string)
- func (tkr *Tracker) PutLeecher(infohash string, p *models.Peer) (err error)
- func (tkr *Tracker) PutSeeder(infohash string, p *models.Peer) (err error)
- func (tkr *Tracker) PutTorrent(torrent *models.Torrent) (err error)
- func (tkr *Tracker) RegisterUser(u *models.User) (user *models.User, err error)
- func (tkr *Tracker) TouchTorrent(infohash string) (err error)
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func NewStorage ¶
func (*Storage) ClientApproved ¶
func (*Storage) DeleteClient ¶
func (*Storage) DeleteLeecher ¶
func (*Storage) DeleteSeeder ¶
func (*Storage) DeleteTorrent ¶
func (*Storage) DeleteUser ¶
func (*Storage) DumpTorrents ¶
func (*Storage) FindTorrent ¶
func (*Storage) IncrementTorrentSnatches ¶
func (*Storage) PurgeInactivePeers ¶
func (*Storage) PurgeInactiveTorrent ¶
func (*Storage) PutTorrent ¶
func (*Storage) TouchTorrent ¶
type Tracker ¶
Tracker represents the logic necessary to service BitTorrent announces, independently of the underlying data transports used.
func New ¶
New creates a new Tracker, and opens any necessary connections. Maintenance routines are automatically spawned in the background.
func (*Tracker) ClientApproved ¶
check if a peerID is approved
func (*Tracker) DeleteLeecher ¶
delete leecher from cache
func (*Tracker) DeleteSeeder ¶
delete seeder from cache
func (*Tracker) DeleteTorrent ¶
delete torrent from database
func (*Tracker) DeleteUser ¶
func (*Tracker) FindTorrent ¶
find a torrent, checks cache then looks it up
func (*Tracker) HandleAnnounce ¶
HandleAnnounce encapsulates all of the logic of handling a BitTorrent client's Announce without being coupled to any transport protocol.
func (*Tracker) HandleScrape ¶
HandleScrape encapsulates all the logic of handling a BitTorrent client's scrape without being coupled to any transport protocol.
func (*Tracker) IncrementTorrentSnatches ¶
increment snatches for a torrent with an infohash
func (*Tracker) LoadApprovedClients ¶
LoadApprovedClients loads a list of client IDs into the tracker's storage.
func (*Tracker) PurgeInactiveTorrent ¶
purge an inactive torrent from the cache
func (*Tracker) PutLeecher ¶
put a leecher into the cache
func (*Tracker) PutTorrent ¶
put a torrent into the database
func (*Tracker) RegisterUser ¶
put new user into database populate the user model with info
func (*Tracker) TouchTorrent ¶
touch a torrent in cache
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.