Skip to content

Commit

Permalink
add support for --peer-port. fixes #107 and cc #89
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Aug 30, 2014
1 parent 477cba1 commit d8a563c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var argv = rc('peerflix', {}, optimist
.alias('a', 'all').describe('a', 'select all files in the torrent')
.alias('r', 'remove').describe('r', 'remove files on exit')
.alias('e', 'peer').describe('e', 'add peer by ip:port')
.alias('x', 'peer-port').describe('x', 'set peer listening port')
.describe('version', 'prints current version')
.argv);

Expand Down Expand Up @@ -66,6 +67,8 @@ if (argv.t) {
var noop = function() {};

var ontorrent = function(torrent) {
if (argv['peer-port']) argv.peerPort = Number(argv['peer-port'])

var engine = peerflix(torrent, argv);
var hotswaps = 0;
var verified = 0;
Expand All @@ -79,6 +82,7 @@ var ontorrent = function(torrent) {
invalid++;
});


if (argv.list) {
var onready = function() {
engine.files.forEach(function(file, i, files) {
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ module.exports = function(torrent, opts) {
engine.server = createServer(engine, opts.index);

// Listen when torrent-stream is ready, by default a random port.
engine.on('ready', function() { engine.server.listen(opts.port || 0); });
engine.on('ready', function() {
engine.server.listen(opts.port || 0);
});

if (opts.peerPort) engine.listen(opts.peerPort);

return engine;
};

0 comments on commit d8a563c

Please sign in to comment.