aboutsummaryrefslogtreecommitdiff
path: root/plugin/torrent/session.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2020-07-27 10:15:49 +0200
committerGravatar Miek Gieben <miek@miek.nl> 2020-07-27 10:15:49 +0200
commitef33425487033c6c68610ecf763b2185df4df3e5 (patch)
tree69b52554b40bd31a03f032ed0467e11f4834e148 /plugin/torrent/session.go
parent05751bdb59737221367f13413a83451e38bce355 (diff)
downloadcoredns-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.go25
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)
+ }
+
+}