2016-08-09 21:01:36 +02:00
|
|
|
package frontend
|
2016-08-07 19:40:24 +02:00
|
|
|
|
|
|
|
import (
|
2016-08-17 04:32:15 +02:00
|
|
|
"context"
|
2016-08-09 21:21:59 +02:00
|
|
|
|
2016-08-17 03:42:08 +02:00
|
|
|
"github.com/chihaya/chihaya/bittorrent"
|
2016-08-07 19:40:24 +02:00
|
|
|
)
|
|
|
|
|
2016-08-10 01:28:59 +02:00
|
|
|
// TrackerLogic is the interface used by a frontend in order to: (1) generate a
|
|
|
|
// response from a parsed request, and (2) asynchronously observe anything
|
2016-08-07 19:40:24 +02:00
|
|
|
// after the response has been delivered to the client.
|
2016-08-10 01:28:59 +02:00
|
|
|
type TrackerLogic interface {
|
2016-08-09 21:21:59 +02:00
|
|
|
// HandleAnnounce generates a response for an Announce.
|
2017-06-06 04:53:17 +02:00
|
|
|
//
|
|
|
|
// Returns the updated context, the generated AnnounceResponse and no error
|
|
|
|
// on success; nil and error on failure.
|
|
|
|
HandleAnnounce(context.Context, *bittorrent.AnnounceRequest) (context.Context, *bittorrent.AnnounceResponse, error)
|
2016-08-07 19:40:24 +02:00
|
|
|
|
2016-08-09 21:21:59 +02:00
|
|
|
// AfterAnnounce does something with the results of an Announce after it
|
|
|
|
// has been completed.
|
|
|
|
AfterAnnounce(context.Context, *bittorrent.AnnounceRequest, *bittorrent.AnnounceResponse)
|
2016-08-07 19:40:24 +02:00
|
|
|
|
2016-08-09 21:21:59 +02:00
|
|
|
// HandleScrape generates a response for a Scrape.
|
2017-06-06 04:53:17 +02:00
|
|
|
//
|
|
|
|
// Returns the updated context, the generated AnnounceResponse and no error
|
|
|
|
// on success; nil and error on failure.
|
|
|
|
HandleScrape(context.Context, *bittorrent.ScrapeRequest) (context.Context, *bittorrent.ScrapeResponse, error)
|
2016-08-07 19:40:24 +02:00
|
|
|
|
2016-08-09 21:21:59 +02:00
|
|
|
// AfterScrape does something with the results of a Scrape after it has been completed.
|
|
|
|
AfterScrape(context.Context, *bittorrent.ScrapeRequest, *bittorrent.ScrapeResponse)
|
|
|
|
}
|