Add a scrape command so I can work out if trackers are seeing my test clients
I don't even know if scrape is the right word.
This commit is contained in:
parent
9ee83455cf
commit
771a08d4f4
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bitbucket.org/anacrolix/go.torrent"
|
||||
"bitbucket.org/anacrolix/go.torrent/tracker"
|
||||
_ "bitbucket.org/anacrolix/go.torrent/tracker/udp"
|
||||
"flag"
|
||||
metainfo "github.com/nsf/libtorgo/torrent"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
mi, err := metainfo.Load(os.Stdin)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for _, tier := range mi.AnnounceList {
|
||||
for _, url := range tier {
|
||||
tr, err := tracker.New(url)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = tr.Connect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
resp, err := tr.Announce(&tracker.AnnounceRequest{
|
||||
NumWant: -1,
|
||||
InfoHash: torrent.BytesInfoHash(mi.InfoHash),
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Print(resp)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue