]> Sergey Matveev's repositories - btrtrc.git/blobdiff - tracker/udp.go
Support scraping from HTTP trackers
[btrtrc.git] / tracker / udp.go
index db486948a675447208c388cf18bbb488495fece2..cf68188751d6c0bda395936a176f6cc38e17ebc9 100644 (file)
@@ -4,8 +4,11 @@ import (
        "context"
        "encoding/binary"
 
+       "github.com/anacrolix/generics"
+
        trHttp "github.com/anacrolix/torrent/tracker/http"
        "github.com/anacrolix/torrent/tracker/udp"
+       "github.com/anacrolix/torrent/types/infohash"
 )
 
 type udpClient struct {
@@ -13,6 +16,15 @@ type udpClient struct {
        requestUri string
 }
 
+func (c *udpClient) Scrape(ctx context.Context, ihs []infohash.T) (out udp.ScrapeResponse, err error) {
+       return c.cl.Client.Scrape(
+               ctx,
+               generics.SliceMap(ihs, func(from infohash.T) udp.InfoHash {
+                       return from
+               }),
+       )
+}
+
 func (c *udpClient) Close() error {
        return c.cl.Close()
 }