mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
26 lines
470 B
Go
26 lines
470 B
Go
|
|
package torrent
|
||
|
|
|
||
|
|
import (
|
||
|
|
"log"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
rtorrent "github.com/cenkalti/rain/torrent"
|
||
|
|
)
|
||
|
|
|
||
|
|
func (t *Torrent) StartSession() error {
|
||
|
|
s, err := rtorrent.NewSession(torrent.DefaultConfig)
|
||
|
|
if err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
// Add magnet link
|
||
|
|
tor, _ := ses.AddURI(magnetLink, nil)
|
||
|
|
|
||
|
|
// Watch the progress
|
||
|
|
for range time.Tick(time.Second) {
|
||
|
|
s := tor.Stats()
|
||
|
|
log.Printf("Status: %s, Downloaded: %d, Peers: %d", s.Status.String(), s.Bytes.Completed, s.Peers.Total)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|