Skip to content

Commit

Permalink
Allow specifying incoming torrent port
Browse files Browse the repository at this point in the history
  • Loading branch information
nochso committed Jul 15, 2016
1 parent ca06a24 commit d33cf0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down

0 comments on commit d33cf0e

Please sign in to comment.