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 (
|
2016-08-17 04:32:15 +02:00
|
|
|
"context"
|
2016-08-05 07:47:04 +02:00
|
|
|
|
2016-08-17 03:42:08 +02:00
|
|
|
"github.com/chihaya/chihaya/bittorrent"
|
2016-08-05 07:47:04 +02:00
|
|
|
)
|
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-17 03:01:58 +02:00
|
|
|
func (nopHook) HandleAnnounce(ctx context.Context, req *bittorrent.AnnounceRequest, resp *bittorrent.AnnounceResponse) error {
|
2016-08-09 22:01:14 +02:00
|
|
|
return nil
|
2016-08-03 09:11:52 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 03:01:58 +02:00
|
|
|
func (nopHook) HandleScrape(ctx context.Context, req *bittorrent.ScrapeRequest, resp *bittorrent.ScrapeResponse) error {
|
2016-08-09 22:01:14 +02:00
|
|
|
return nil
|
2016-08-03 09:11:52 +02:00
|
|
|
}
|