Skip to content

Commit

Permalink
Added support for disabling upload when using Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
glblduh committed May 18, 2022
1 parent 9ac41a0 commit 0879e0b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Simple REST API controlled BitTorrent client
```
docker run -d \
--name torrenttp \
-p 1010:1010 \
-v ~/tttpdl:/dl \
-p 1010:1010 \ # Change the 1010 on the left to change the listening port
-v ~/tttpdl:/dl \ # Change the ~/tttpdl to the download path
-e NOUP=false \ # Set to true to disable uploads
--restart unless-stopped \
glbl/torrenttp:latest
```
Expand Down
4 changes: 3 additions & 1 deletion engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import (

// Creates the BitTorrent client
func (Engine *btEng) initialize(opts *torrent.ClientConfig) {
/* Make client with confs */
// Saves the given config to the Engine
Engine.ClientConfig = opts

/* Make client with confs */
var err error
Engine.Client, err = torrent.NewClient(Engine.ClientConfig)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -94,6 +95,13 @@ func getTorrentFile(t *torrent.Torrent, displaypath string) (*torrent.File, erro
// Create config for BitTorrent client with confs from args
func newBtCliConfs(dir string, noup bool) *torrent.ClientConfig {
opts := torrent.NewDefaultClientConfig()

/* Disables upload if ENV variable is set to true */
if os.Getenv("NOUP") == "true" {
noup = true
}

/* Sets the variables */
opts.DataDir = filepath.Clean(dir)
opts.NoUpload = noup
return opts
Expand Down

0 comments on commit 0879e0b

Please sign in to comment.