diff options
author | 2020-07-27 10:15:49 +0200 | |
---|---|---|
committer | 2020-07-27 10:15:49 +0200 | |
commit | ef33425487033c6c68610ecf763b2185df4df3e5 (patch) | |
tree | 69b52554b40bd31a03f032ed0467e11f4834e148 /plugin/torrent/session.go | |
parent | 05751bdb59737221367f13413a83451e38bce355 (diff) | |
download | coredns-ef33425487033c6c68610ecf763b2185df4df3e5.tar.gz coredns-ef33425487033c6c68610ecf763b2185df4df3e5.tar.zst coredns-ef33425487033c6c68610ecf763b2185df4df3e5.zip |
Add setup func
Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/torrent/session.go')
-rw-r--r-- | plugin/torrent/session.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/plugin/torrent/session.go b/plugin/torrent/session.go new file mode 100644 index 000000000..3b3a35a41 --- /dev/null +++ b/plugin/torrent/session.go @@ -0,0 +1,25 @@ +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) + } + +} |