Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/cmd.js25
-rw-r--r--index.js3
2 files changed, 11 insertions, 17 deletions
diff --git a/bin/cmd.js b/bin/cmd.js
index 4f9d348..795f5a3 100755
--- a/bin/cmd.js
+++ b/bin/cmd.js
@@ -140,9 +140,8 @@ function getRuntime () {
}
var client = new WebTorrent({
- list: argv.list,
blocklist: argv.blocklist,
- port: argv.port
+ port: !argv.list && argv.port
})
.on('error', errorAndExit)
@@ -175,8 +174,8 @@ torrent.on('infoHash', function () {
}
})
-client.on('torrent', function (torrent) {
- if (client.listening) onTorrent(torrent)
+torrent.on('ready', function () {
+ if (client.listening || argv.list) onTorrent(torrent)
else client.on('listening', onTorrent)
})
@@ -187,8 +186,15 @@ function onTorrent (torrent) {
swarm = torrent.swarm
wires = torrent.swarm.wires
+ if (argv.list) {
+ torrent.files.forEach(function (file, i) {
+ clivas.line('{3+bold:' + i + '} : {magenta:' + file.name + '}')
+ })
+ process.exit(0)
+ }
+
torrent.on('verifying', function (data) {
- if (argv.quiet || argv.list) return
+ if (argv.quiet) return
clivas.clear()
clivas.line(
'{green:verifying existing torrent} {bold:'+Math.floor(data.percentDone)+'%} ' +
@@ -197,8 +203,6 @@ function onTorrent (torrent) {
})
torrent.on('done', function () {
- if (argv.list) return
-
if (!argv.quiet) {
// TODO: expose this data from bittorrent-swarm
var numActiveWires = torrent.swarm.wires.reduce(function (num, wire) {
@@ -220,13 +224,6 @@ function onTorrent (torrent) {
}
})
- if (argv.list) {
- torrent.files.forEach(function (file, i) {
- clivas.line('{3+bold:' + i + '} : {magenta:' + file.name + '}')
- })
- process.exit(0)
- }
-
var href
if (client.server) {
href = 'http://' + networkAddress() + ':' + client.server.address().port + '/'
diff --git a/index.js b/index.js
index 0f58e3e..e575fca 100644
--- a/index.js
+++ b/index.js
@@ -68,9 +68,6 @@ function WebTorrent (opts) {
debug('new webtorrent (peerId %s, nodeId %s)', self.peerIdHex, self.nodeIdHex)
- // TODO: this is probably broken
- if (opts.list) return
-
if (opts.port !== false && typeof Server === 'function' /* browser exclude */) {
self.server = new Server(self, opts.port)
self.server.on('listening', function () {