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