2
0
mirror of synced 2025-02-23 22:28:11 +00:00

Set tracker announce numWant to 0 if we're unable to dial

This commit is contained in:
Matt Joiner 2020-04-16 12:02:34 +10:00
parent 74986db9ed
commit eec337d4bc
2 changed files with 11 additions and 5 deletions

View File

@ -1379,11 +1379,17 @@ func (t *Torrent) startMissingTrackerScrapers() {
// Returns an AnnounceRequest with fields filled out to defaults and current
// values.
func (t *Torrent) announceRequest(event tracker.AnnounceEvent) tracker.AnnounceRequest {
// Note that IPAddress is not set. It's set for UDP inside the tracker
// code, since it's dependent on the network in use.
// Note that IPAddress is not set. It's set for UDP inside the tracker code, since it's
// dependent on the network in use.
return tracker.AnnounceRequest{
Event: event,
NumWant: -1,
Event: event,
NumWant: func() int32 {
if t.wantPeers() && len(t.cl.dialers) > 0 {
return -1
} else {
return 0
}
}(),
Port: uint16(t.cl.incomingPeerPort()),
PeerId: t.cl.peerID,
InfoHash: t.infoHash,

View File

@ -116,7 +116,7 @@ func (me *trackerScraper) announce(event tracker.AnnounceEvent) (ret trackerAnno
me.t.cl.rLock()
req := me.t.announceRequest(event)
me.t.cl.rUnlock()
//log.Printf("announcing %s %s to %q", me.t, req.Event, me.u.String())
me.t.logger.Printf("announcing to %q: %#v", me.u.String(), req)
res, err := tracker.Announce{
HTTPProxy: me.t.cl.config.HTTPProxy,
UserAgent: me.t.cl.config.HTTPUserAgent,