From d33cf0e626095c8964e236e9327bfc804f27748d Mon Sep 17 00:00:00 2001 From: Marcel Voigt Date: Mon, 7 Mar 2016 20:46:08 +0100 Subject: [PATCH] Allow specifying incoming torrent port --- client.go | 3 ++- main.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 0210a5f..818aa06 100644 --- a/client.go +++ b/client.go @@ -45,7 +45,7 @@ type Client struct { // NewClient creates a new torrent client based on a magnet or a torrent file. // If the torrent file is on http, we try downloading it. -func NewClient(torrentPath string, port int, seed bool, tcp bool, maxConnections int) (client Client, err error) { +func NewClient(torrentPath string, port int, torrentPort int, seed bool, tcp bool, maxConnections int) (client Client, err error) { var t *torrent.Torrent var c *torrent.Client @@ -57,6 +57,7 @@ func NewClient(torrentPath string, port int, seed bool, tcp bool, maxConnections NoUpload: !seed, Seed: seed, DisableTCP: !tcp, + ListenAddr: fmt.Sprintf(":%d", torrentPort), }) if err != nil { diff --git a/main.go b/main.go index a6140d6..53abc26 100644 --- a/main.go +++ b/main.go @@ -20,13 +20,14 @@ const ( func main() { // Parse flags. - var port int + var port, torrentPort int var seed, tcp *bool var player *string var maxConnections int player = flag.String("player", "", "Open the stream with a video player ("+joinPlayerNames()+")") flag.IntVar(&port, "port", 8080, "Port to stream the video on") + flag.IntVar(&torrentPort, "torrent-port", 6882, "Port to listen for incoming torrent connections") seed = flag.Bool("seed", false, "Seed after finished downloading") flag.IntVar(&maxConnections, "conn", 200, "Maximum number of connections") tcp = flag.Bool("tcp", true, "Allow connections via TCP") @@ -37,7 +38,7 @@ func main() { } // Start up the torrent client. - client, err := NewClient(flag.Arg(0), port, *seed, *tcp, maxConnections) + client, err := NewClient(flag.Arg(0), port, torrentPort, *seed, *tcp, maxConnections) if err != nil { log.Fatalf(err.Error()) os.Exit(exitErrorInClient)