t.addTrackers(announceList)
}
+func (t *Torrent) ModifyTrackers(announceList [][]string) {
+ t.cl.lock()
+ defer t.cl.unlock()
+ t.modifyTrackers(announceList)
+}
+
func (t *Torrent) Piece(i pieceIndex) *Piece {
return t.piece(i)
}
t.updateWantPeersEvent()
}
+func (t *Torrent) modifyTrackers(announceList [][]string) {
+ var workers errgroup.Group
+ for _, v := range t.trackerAnnouncers {
+ workers.Go(func() error {
+ v.Stop()
+ return nil
+ })
+ }
+ workers.Wait()
+
+ clear(t.metainfo.AnnounceList)
+ t.addTrackers(announceList)
+}
+
// Don't call this before the info is available.
func (t *Torrent) bytesCompleted() int64 {
if !t.haveInfo() {
u: *u,
t: t,
lookupTrackerIp: t.cl.config.LookupTrackerIp,
+ stopCh: make(chan struct{}),
}
go newAnnouncer.Run()
return newAnnouncer
"fmt"
"net"
"net/url"
+ "sync"
"time"
"github.com/anacrolix/dht/v2/krpc"
t *Torrent
lastAnnounce trackerAnnounceResult
lookupTrackerIp func(*url.URL) ([]net.IP, error)
+
+ stopOnce sync.Once
+ stopCh chan struct{}
}
type torrentTrackerAnnouncer interface {
statusLine() string
URL() *url.URL
+
+ Stop()
}
func (me trackerScraper) URL() *url.URL {
}
}
+func (me *trackerScraper) Stop() {
+ me.stopOnce.Do(func() {
+ close(me.stopCh)
+ })
+}
+
func (me *trackerScraper) Run() {
defer me.announceStopped()
}
select {
+ case <-me.stopCh:
+ return
case <-me.t.closed.Done():
return
case <-reconsider:
}
}
return buf.Bytes(), err
-}
\ No newline at end of file
+}
return &me.url
}
+func (me websocketTrackerStatus) Stop() {
+}
+
type refCountedWebtorrentTrackerClient struct {
webtorrent.TrackerClient
refCount int