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 Mar 7, 2016
1 parent 2cf9553 commit 441ce85
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 @@ -43,7 +43,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) (client Client, err error) {
func NewClient(torrentPath string, port int, torrentPort int, seed bool, tcp bool) (client Client, err error) {
var t torrent.Torrent
var c *torrent.Client

Expand All @@ -55,6 +55,7 @@ func NewClient(torrentPath string, port int, seed bool, tcp bool) (client Client
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,12 +20,13 @@ const (

func main() {
// Parse flags.
var port int
var port, torrentPort int
var seed, tcp *bool
var player *string

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")
tcp = flag.Bool("tcp", true, "Allow connections via TCP")
flag.Parse()
Expand All @@ -35,7 +36,7 @@ func main() {
}

// Start up the torrent client.
client, err := NewClient(flag.Arg(0), port, *seed, *tcp)
client, err := NewClient(flag.Arg(0), port, torrentPort, *seed, *tcp)
if err != nil {
log.Fatalf(err.Error())
os.Exit(exitErrorInClient)
Expand Down

0 comments on commit 441ce85

Please sign in to comment.