seedlinux

find open source torrents and stats for people wishing to contribute bandwidth.
git clone git://git.beardyjay.co.uk/seedlinux
Log | Files | Refs | README | LICENSE

commit 8eca9e64d48d78612ae4ca2a39b983ba335102d1
parent f09b72a359e287ac231fdd33425fd405f3bf83b7
Author: Jay Scott <jay@jayscott.co.uk>
Date:   Sat,  1 Jul 2017 22:57:58 +0100

get peer information and update db

Diffstat:
MREADME.md | 23-----------------------
Mcontrollers/torrents_controller.js | 101++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Mpackage-lock.json | 352+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackage.json | 5++++-
Mroutes/torrent_route.js | 1+
5 files changed, 434 insertions(+), 48 deletions(-)

diff --git a/README.md b/README.md @@ -22,29 +22,6 @@ Seed the data using mongo-import tool. mongoimport --db seedlinux --collection torrents --drop --file ./data/dataset.json ``` -Torrents Model - -```json -{ - name: {type: String, required: true, max: 100}, - hash: {type: String, required: true, max: 20}, - created: {type: String}, - comment: {type: String, max: 100}, - announce: [ - {type: String} - ], - files: [{ - path: String, - name: String, - length: Number, - offset: Number - }], - magneturi: {type: String}, - leechers: {type: Number}, - seeders: {type: Number}, -} -``` - ### Stuff used to make this: * [Docker](https://hub.docker.com/_/mongo/) image for MongoDB. diff --git a/controllers/torrents_controller.js b/controllers/torrents_controller.js @@ -1,36 +1,89 @@ 'use strict'; -let Torrent = require('../models/torrent_model'); +const Torrent = require('../models/torrent_model'); const async = require('async'); -exports.index = function(req, res) { - - async.parallel({ - torrent_count: function(callback) { - Torrent.count(callback); - }, - torrent_data: function(callback) { - Torrent.find({},callback); - }, - }, function(err, results) { - res.render('torrent', { title: 'Index Page', data: results }); - }); +function getTorrent(query, callback) { + Torrent.find(query, function(err, data) { + if (err) { + callback(err, null); + } else { + callback(null, data[0]); + } + }); }; -exports.torrent_detail = function(req, res) { - async.parallel({ +function updateTorrent(query, data, callback) { + Torrent.findOneAndUpdate(query, data, function(err, data) { + if (err) { + callback(err, null); + } else { + callback(null, data[0]); + } + }); +}; + +exports.index = function(req, res) { + async.parallel( + { torrent_count: function(callback) { Torrent.count(callback); }, torrent_data: function(callback) { - Torrent.find({hash: req.params.id},callback); + Torrent.find({}, callback); + } + }, + function(err, results) { + res.render('torrent', { title: 'Index Page', data: results }); + } + ); +}; + +exports.torrent_detail = function(req, res) { + async.parallel( + { + torrent_count: function(callback) { + Torrent.count(callback); }, - }, function(err, results) { - if(results.torrent_data == "" ) { - console.log(results); - res.redirect('/'); - } else { - res.render('details', { title: 'Torrent Details', data: results }); - } - }); + torrent_data: function(callback) { + Torrent.find({ hash: req.params.id }, callback); + } + }, + function(err, results) { + if (results.torrent_data == '') { + res.sendStatus(404); + } else { + res.render('details', { title: 'Torrent Details', data: results }); + } + } + ); }; + +exports.torrent_stats = function(req, res) { + + const webtorrentHealth = require('webtorrent-health'); + + getTorrent({hash: req.params.id }, function(err, torrent) { + if (err) res.sendStatus(404); + + if (torrent == null) { + res.sendStatus(404); + } else { + webtorrentHealth(torrent.magneturi, {trackers: torrent.announce}, function (err, data) { + if (err) res.sendStatus(500); + + let newData = { + seeders: data.seeds, + leechers: data.peers, + ratio: Math.round((data.peers > 0 ? data.seeds / data.peers : data.seeds) +'e+2') + 'e-2' + } + + updateTorrent({hash: req.params.id}, newData, function(err, user) { + if (err) res.sendStatus(500); + + res.redirect('/torrent/details/' + req.params.id); + }); + }) + } + }); +} diff --git a/package-lock.json b/package-lock.json @@ -25,6 +25,11 @@ } } }, + "addr-to-ip-port": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/addr-to-ip-port/-/addr-to-ip-port-1.4.2.tgz", + "integrity": "sha1-fkb/Hya3qfXjP9g51XrvYwO0xpI=" + }, "align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", @@ -35,11 +40,28 @@ "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=" }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, "app-root-path": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-2.0.1.tgz", "integrity": "sha1-zWLc+OT9WkF+/GZNLlsQZTxlG0Y=" }, + "aproba": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.1.2.tgz", + "integrity": "sha512-ZpYajIfO0j2cOFTO955KUMIKNmj6zhX8kVztMAxFsDaMwz+9Z9SV0uou2pC9HJqcfpffOsjnbrDMvkNy+9RXPw==", + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", + "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", + "optional": true + }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -72,6 +94,28 @@ } } }, + "bindings": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", + "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=", + "optional": true + }, + "bittorrent-peerid": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/bittorrent-peerid/-/bittorrent-peerid-1.2.0.tgz", + "integrity": "sha1-n2dWEvDmr8bvNFDfulH/cjir83E=" + }, + "bittorrent-tracker": { + "version": "9.2.3", + "resolved": "https://registry.npmjs.org/bittorrent-tracker/-/bittorrent-tracker-9.2.3.tgz", + "integrity": "sha512-KW7nE/Lwxlpy6BmEEufvwXXsAnq7961xsoE8qL2PWrwKqKjEWLIX/T3REdq6o+RQT0YYdmy7NnqVRs/w+2LUjg==" + }, + "bl": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz", + "integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=", + "optional": true + }, "blob-to-buffer": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/blob-to-buffer/-/blob-to-buffer-1.2.6.tgz", @@ -82,6 +126,11 @@ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.2.tgz", "integrity": "sha1-AkpVFylTCIV/FPkfEQb8O1VfRGs=" }, + "bn.js": { + "version": "4.11.7", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.7.tgz", + "integrity": "sha512-LxFiV5mefv0ley0SzqkOPR1bC4EbpPx8LkOz5vMe/Yi15t5hzwgO/G+tc7wOtL4PZTYjwHu8JnEiSLumuSjSfA==" + }, "body-parser": { "version": "1.17.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.17.2.tgz", @@ -104,6 +153,12 @@ "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=" }, + "bufferutil": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-3.0.1.tgz", + "integrity": "sha1-ILLvUVmsSfIORLzjjnw1pqkE7mY=", + "optional": true + }, "bytes": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", @@ -124,6 +179,12 @@ "resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz", "integrity": "sha1-x84o821LzZdE5f/CxfzeHHMmH8A=" }, + "chownr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz", + "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=", + "optional": true + }, "clean-css": { "version": "3.4.27", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.27.tgz", @@ -134,11 +195,26 @@ "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=" }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, "commander": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=" }, + "compact2string": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/compact2string/-/compact2string-1.4.0.tgz", + "integrity": "sha1-qZzZbqAAUlaEsmloOuIiLW7qe0k=" + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, "constantinople": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/constantinople/-/constantinople-3.1.0.tgz", @@ -184,6 +260,18 @@ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" }, + "deep-extend": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", + "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", + "optional": true + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "optional": true + }, "depd": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", @@ -209,6 +297,11 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" }, + "end-of-stream": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", + "integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=" + }, "es6-promise": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz", @@ -224,6 +317,12 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.0.tgz", "integrity": "sha1-b2Ma7zNtbEY2K1F2QETOIWvjwFE=" }, + "expand-template": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-1.0.3.tgz", + "integrity": "sha1-bDAzIxd6YrGyLAcCefeGEoe2mxo=", + "optional": true + }, "express": { "version": "4.15.3", "resolved": "https://registry.npmjs.org/express/-/express-4.15.3.tgz", @@ -248,6 +347,11 @@ } } }, + "flat": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat/-/flat-2.0.1.tgz", + "integrity": "sha1-cOKRiKdL4MPIlAnu0fqVd5B64y8=" + }, "forwarded": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", @@ -263,11 +367,28 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.0.tgz", "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=" }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "optional": true + }, + "get-browser-rtc": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/get-browser-rtc/-/get-browser-rtc-1.0.2.tgz", + "integrity": "sha1-u81AyEUaftTvXDc7gWmkCd0dEdk=" + }, "get-stdin": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=" }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=", + "optional": true + }, "graceful-readlink": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", @@ -278,6 +399,12 @@ "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=" }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "optional": true + }, "hooks-fixed": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.0.tgz", @@ -298,6 +425,17 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, + "ini": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", + "optional": true + }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + }, "ipaddr.js": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz", @@ -313,6 +451,11 @@ "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-2.1.0.tgz", "integrity": "sha1-kb6dR968/vB3l36XIr5tz7RGXvA=" }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=" + }, "is-promise": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", @@ -363,6 +506,11 @@ "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=" }, + "lru": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lru/-/lru-3.1.0.tgz", + "integrity": "sha1-6n+4VG2DczOWoTCR12z+tMBoN9U=" + }, "magnet-uri": { "version": "5.1.7", "resolved": "https://registry.npmjs.org/magnet-uri/-/magnet-uri-5.1.7.tgz", @@ -398,6 +546,23 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=" }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + } + } + }, "mongodb": { "version": "2.2.27", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.27.tgz", @@ -457,11 +622,40 @@ "resolved": "https://registry.npmjs.org/muri/-/muri-1.2.1.tgz", "integrity": "sha1-7H6lzmympSPrGrNbrNpfqBbJqjw=" }, + "nan": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz", + "integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U=", + "optional": true + }, "negotiator": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" }, + "node-abi": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.0.3.tgz", + "integrity": "sha1-DKZ+XmZ7jhNDVJyhcVOoFdC7/ao=", + "optional": true + }, + "noop-logger": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", + "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=", + "optional": true + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "optional": true + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -482,6 +676,12 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=" }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "optional": true + }, "parse-torrent": { "version": "5.8.3", "resolved": "https://registry.npmjs.org/parse-torrent/-/parse-torrent-5.8.3.tgz", @@ -507,6 +707,20 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, + "prebuild-install": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.1.2.tgz", + "integrity": "sha1-2a4MqFMw4Dli2TKS+VqLRMLr9QU=", + "optional": true, + "dependencies": { + "simple-get": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-1.4.3.tgz", + "integrity": "sha1-6XVe2kB+ltpAxeUVjJ6jezO+y+s=", + "optional": true + } + } + }, "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", @@ -594,11 +808,33 @@ "resolved": "https://registry.npmjs.org/pug-walk/-/pug-walk-1.1.3.tgz", "integrity": "sha1-181bI9s8qHxjbIaglz+c2OAwQ2w=" }, + "pump": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.2.tgz", + "integrity": "sha1-Oz7mUS+U8OV1U4wXmV+fFpkKXVE=" + }, "qs": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=" }, + "random-iterate": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/random-iterate/-/random-iterate-1.0.1.tgz", + "integrity": "sha1-99l9kt7mZl7F9toIx/ljytSyrJk=" + }, + "randombytes": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", + "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "dependencies": { + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + } + } + }, "range-parser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", @@ -609,6 +845,12 @@ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.2.0.tgz", "integrity": "sha1-mUl2z2pQlqQRYoQEkvC9xdbn+5Y=" }, + "rc": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.1.tgz", + "integrity": "sha1-LgPo5C7kULjLPc5lvhv4l04d/ZU=", + "optional": true + }, "readable-stream": { "version": "2.2.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz", @@ -644,6 +886,16 @@ "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=" }, + "run-parallel": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.6.tgz", + "integrity": "sha1-KQA8miFj4B4tLfyQV18sbB1hoDk=" + }, + "run-series": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/run-series/-/run-series-1.1.4.tgz", + "integrity": "sha1-iac93F51ye+KtjIMChYA1qQRebk=" + }, "rusha": { "version": "0.8.6", "resolved": "https://registry.npmjs.org/rusha/-/rusha-0.8.6.tgz", @@ -681,11 +933,23 @@ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.12.3.tgz", "integrity": "sha1-n0uhni8wMMVH+K+ZEHg47DjVseI=" }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "optional": true + }, "setprototypeof": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "optional": true + }, "simple-concat": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", @@ -703,11 +967,28 @@ } } }, + "simple-peer": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/simple-peer/-/simple-peer-8.1.1.tgz", + "integrity": "sha512-t2zRYgj1HE5lbfkuL2bJ8s8Q60TQfPwOfDj/TA1/N/Qvi8pdj4uEU0bctrZIsHZlzuU7HM+RFR/YBbiLJjHpxQ==" + }, "simple-sha1": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/simple-sha1/-/simple-sha1-2.1.0.tgz", "integrity": "sha1-lCe7lv8SY8wQqEFM7dUaGLkZ6LM=" }, + "simple-websocket": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/simple-websocket/-/simple-websocket-5.0.2.tgz", + "integrity": "sha1-BA2Q3qnkGZqXYTOUzmiTLErvPUQ=", + "dependencies": { + "ws": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-2.3.1.tgz", + "integrity": "sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=" + } + } + }, "sliced": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", @@ -735,6 +1016,39 @@ } } }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=" + }, + "string2compact": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/string2compact/-/string2compact-1.2.2.tgz", + "integrity": "sha1-Qgs6nuHEaFSRm0oq6sZcQ/pQWXs=" + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=" + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "optional": true + }, + "tar-fs": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.15.3.tgz", + "integrity": "sha1-7M+TXpQUk9gVECjmNuUc5MPKfyA=", + "optional": true + }, + "tar-stream": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.5.4.tgz", + "integrity": "sha1-NlSc8E7RrumyowwBQyUiONr5QBY=", + "optional": true + }, "thirty-two": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/thirty-two/-/thirty-two-1.0.2.tgz", @@ -745,6 +1059,12 @@ "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-0.0.1.tgz", "integrity": "sha1-zu78cXp2xDFvEm0LnbqlXX598Bo=" }, + "tunnel-agent": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", + "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", + "optional": true + }, "type-is": { "version": "1.6.15", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", @@ -768,16 +1088,32 @@ "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", "optional": true }, + "ultron": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.0.tgz", + "integrity": "sha1-sHoualQagV/Go0zNRTO67DB8qGQ=" + }, "uniq": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=" }, + "unordered-array-remove": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unordered-array-remove/-/unordered-array-remove-1.0.2.tgz", + "integrity": "sha1-xUbo+I4xegzyZEyX7LV9umbSUO8=" + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, + "unzip-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-1.0.2.tgz", + "integrity": "sha1-uYTwh3/AqJwsdzzB73tbIytbBv4=", + "optional": true + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -798,6 +1134,17 @@ "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=" }, + "webtorrent-health": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/webtorrent-health/-/webtorrent-health-1.1.1.tgz", + "integrity": "sha1-OOi6WUgUHrwWkzIZanMNBw94pEY=" + }, + "wide-align": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", + "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", + "optional": true + }, "window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", @@ -818,6 +1165,11 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "ws": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.0.0.tgz", + "integrity": "sha1-mN2wAFbIOQy3Ued4h4hJf5kQO2w=" + }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", diff --git a/package.json b/package.json @@ -9,14 +9,17 @@ "dependencies": { "app-root-path": "^2.0.1", "async": "^2.5.0", + "bittorrent-tracker": "^9.2.3", "body-parser": "~1.17.1", "cookie-parser": "~1.4.3", "debug": "~2.6.3", "express": "~4.15.2", + "flat": "^2.0.1", "mongoose": "4.10.8", "morgan": "~1.8.1", "parse-torrent": "^5.8.3", "pug": "~2.0.0-beta11", - "serve-favicon": "~2.4.2" + "serve-favicon": "~2.4.2", + "webtorrent-health": "^1.1.1" } } diff --git a/routes/torrent_route.js b/routes/torrent_route.js @@ -5,5 +5,6 @@ const router = express.Router(); const torrent_controller = require('../controllers/torrents_controller'); router.get('/details/:id', torrent_controller.torrent_detail); +router.get('/stats/:id', torrent_controller.torrent_stats); module.exports = router;