2020-04-10 13:27:30 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/davecgh/go-spew/spew"
|
|
|
|
|
|
|
|
"github.com/anacrolix/torrent"
|
|
|
|
"github.com/anacrolix/torrent/tracker"
|
|
|
|
)
|
|
|
|
|
2021-01-04 10:37:44 +08:00
|
|
|
type AnnounceCmd struct {
|
|
|
|
Tracker string `arg:"positional"`
|
|
|
|
InfoHash torrent.InfoHash
|
|
|
|
}
|
|
|
|
|
2021-09-07 10:08:31 +08:00
|
|
|
func announceErr(flags AnnounceCmd) error {
|
2020-04-10 13:27:30 +08:00
|
|
|
response, err := tracker.Announce{
|
|
|
|
TrackerUrl: flags.Tracker,
|
|
|
|
Request: tracker.AnnounceRequest{
|
|
|
|
InfoHash: flags.InfoHash,
|
|
|
|
Port: uint16(torrent.NewDefaultClientConfig().ListenPort),
|
2022-03-02 07:51:19 +08:00
|
|
|
NumWant: -1,
|
2020-04-10 13:27:30 +08:00
|
|
|
},
|
|
|
|
}.Do()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("doing announce: %w", err)
|
|
|
|
}
|
|
|
|
spew.Dump(response)
|
|
|
|
return nil
|
|
|
|
}
|