Skip to content

Commit

Permalink
Add --port flag to announce
Browse files Browse the repository at this point in the history
(cherry picked from commit e554aa1)
  • Loading branch information
anacrolix committed Dec 25, 2022
1 parent 8710500 commit e235776
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cmd/torrent/announce.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@ import (

type AnnounceCmd struct {
Event udp.AnnounceEvent
Port *uint16
Tracker string `arg:"positional"`
InfoHash torrent.InfoHash `arg:"positional"`
}

func announceErr(flags AnnounceCmd) error {
req := tracker.AnnounceRequest{
InfoHash: flags.InfoHash,
Port: uint16(torrent.NewDefaultClientConfig().ListenPort),
NumWant: -1,
Event: flags.Event,
}
if flags.Port != nil {
req.Port = *flags.Port
}
response, err := tracker.Announce{
TrackerUrl: flags.Tracker,
Request: tracker.AnnounceRequest{
InfoHash: flags.InfoHash,
Port: uint16(torrent.NewDefaultClientConfig().ListenPort),
NumWant: -1,
Event: flags.Event,
},
Request: req,
}.Do()
if err != nil {
return fmt.Errorf("doing announce: %w", err)
Expand Down

0 comments on commit e235776

Please sign in to comment.