2016-08-10 02:08:15 +02:00
|
|
|
package middleware
|
2016-08-03 09:11:52 +02:00
|
|
|
|
2016-08-05 07:47:04 +02:00
|
|
|
import (
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
|
|
|
|
"github.com/jzelinskie/trakr/bittorrent"
|
|
|
|
)
|
2016-08-03 09:11:52 +02:00
|
|
|
|
|
|
|
// Hook abstracts the concept of anything that needs to interact with a
|
|
|
|
// BitTorrent client's request and response to a BitTorrent tracker.
|
|
|
|
type Hook interface {
|
2016-08-05 07:47:04 +02:00
|
|
|
HandleAnnounce(context.Context, *bittorrent.AnnounceRequest, *bittorrent.AnnounceResponse) error
|
|
|
|
HandleScrape(context.Context, *bittorrent.ScrapeRequest, *bittorrent.ScrapeResponse) error
|
2016-08-03 09:11:52 +02:00
|
|
|
}
|
|
|
|
|
2016-08-09 22:01:14 +02:00
|
|
|
type nopHook struct{}
|
2016-08-03 09:11:52 +02:00
|
|
|
|
2016-08-09 22:01:14 +02:00
|
|
|
func (nopHook) HandleAnnounce(context.Context, *bittorrent.AnnounceRequest, *bittorrent.AnnounceResponse) error {
|
|
|
|
return nil
|
2016-08-03 09:11:52 +02:00
|
|
|
}
|
|
|
|
|
2016-08-09 22:01:14 +02:00
|
|
|
func (nopHook) HandleScrape(context.Context, *bittorrent.ScrapeRequest, *bittorrent.ScrapeResponse) error {
|
|
|
|
return nil
|
2016-08-03 09:11:52 +02:00
|
|
|
}
|