Add --port flag to announce
This commit is contained in:
parent
16c7621d9e
commit
e554aa19a6
|
@ -12,19 +12,24 @@ import (
|
||||||
|
|
||||||
type AnnounceCmd struct {
|
type AnnounceCmd struct {
|
||||||
Event udp.AnnounceEvent
|
Event udp.AnnounceEvent
|
||||||
|
Port *uint16
|
||||||
Tracker string `arg:"positional"`
|
Tracker string `arg:"positional"`
|
||||||
InfoHash torrent.InfoHash `arg:"positional"`
|
InfoHash torrent.InfoHash `arg:"positional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func announceErr(flags AnnounceCmd) error {
|
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{
|
response, err := tracker.Announce{
|
||||||
TrackerUrl: flags.Tracker,
|
TrackerUrl: flags.Tracker,
|
||||||
Request: tracker.AnnounceRequest{
|
Request: req,
|
||||||
InfoHash: flags.InfoHash,
|
|
||||||
Port: uint16(torrent.NewDefaultClientConfig().ListenPort),
|
|
||||||
NumWant: -1,
|
|
||||||
Event: flags.Event,
|
|
||||||
},
|
|
||||||
}.Do()
|
}.Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("doing announce: %w", err)
|
return fmt.Errorf("doing announce: %w", err)
|
||||||
|
|
Loading…
Reference in New Issue