FedP2P/cmd/torrent/announce.go

32 lines
606 B
Go

package main
import (
"fmt"
"github.com/davecgh/go-spew/spew"
"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/tracker"
)
type AnnounceCmd struct {
Tracker string `arg:"positional"`
InfoHash torrent.InfoHash
}
func announceErr(flags AnnounceCmd) error {
response, err := tracker.Announce{
TrackerUrl: flags.Tracker,
Request: tracker.AnnounceRequest{
InfoHash: flags.InfoHash,
Port: uint16(torrent.NewDefaultClientConfig().ListenPort),
NumWant: -1,
},
}.Do()
if err != nil {
return fmt.Errorf("doing announce: %w", err)
}
spew.Dump(response)
return nil
}