diff --git a/README.md b/README.md index 03bab226..527c9333 100644 --- a/README.md +++ b/README.md @@ -255,13 +255,10 @@ such as: announcePrefix: '[mean.im].', admin: 'admin@mean.im', baseUrl: 'http://mean.im', - clientBlackListUrl: '/about/black', - privateTorrentCmsMode: true + clientBlackListUrl: '/about/black' }, ``` meanTorrent tracker is private, please set the `announce.url` to your server url, then when user to upload torrent file, It will autocheck the torrent announce url whether matching as `announce.url`. -But, meanTorrent support public tracker torrents CMS mode with `privateTorrentCmsMode` set to `false`, in `public` mode, user can upload and download public tracker torrent files, but these torrent files is can not -used by meanTorrent tracker server. ```javascript tmdbConfig: { diff --git a/config/env/torrents.js b/config/env/torrents.js index 0b9a738c..a8c7fd06 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -71,9 +71,6 @@ module.exports = { * @announcePrefix: prefix of torrent file name, is will auto add when user download the torrent files * @admin: site admin mail address * @clientBlackListUrl: forbidden download client list url, user can view this list to check forbidden client software - * @privateTorrentCmsMode: meanTorrent default tracker server mode is private (value true), the tracker server only accept private mode. - * but, you can set this value to false to make a public torrent cms web site without tracker server and announce function. - * if this value is false(public mode), server can scrape all torrent status from owner tracker server * @downloadCheck: announce download(leech) settings * @ratio: if less than this value, can not download(leech) * @checkAfterSignupDays: all users download check start {value} days after signup, so the newest register user has {value} days to upgrade his ratio value, @@ -96,7 +93,6 @@ module.exports = { announcePrefix: '{' + commonEnvConfig.variable.site.site_namekey + '}.', admin: commonEnvConfig.variable.site.site_admin_mail, clientBlackListUrl: '/about/black', - privateTorrentCmsMode: true, downloadCheck: { ratio: 1, checkAfterSignupDays: 30 @@ -141,29 +137,6 @@ module.exports = { image_url: '/modules/core/client/img/rss.jpeg' }, - /** - * @scrapeTorrentsStatus - * - * This option used only when public cms mode (announce.privateTorrentCmsMode = false), - * This defines the timing of scrape torrent status from other tracker server - * NOTE: you can change these value at anytime if you understand it - * - * @scrapeInterval: scrape interval with torrent last_scrape, Avoid frequent scrape, unit in hours - * @onTorrentUpload: scrape status at server side when the torrent uploaded by a user (= init the status info) - * @onTorrentInHome: scrape each torrent status at client side when load into home page (= update the status info) - * @onTorrentInList: scrape each torrent status at client side when load into torrent list page (= update the status info) - * if too more items list in one page, this will make efficiency very low - * @onTorrentInDetail: scrape current torrent status at client side when load torrent detail info, - * if onTorrentInHome and onTorrentInList is true, this value recommend to false - */ - scrapeTorrentStatus: { - scrapeInterval: 2, - onTorrentUpload: true, - onTorrentInHome: true, - onTorrentInList: true, - onTorrentInDetail: false - }, - /** * @ircAnnounce * diff --git a/config/lib/scrape.js b/config/lib/scrape.js deleted file mode 100644 index d18e65e5..00000000 --- a/config/lib/scrape.js +++ /dev/null @@ -1,229 +0,0 @@ -'use strict'; - -var path = require('path'), - bencoding = require('bencoding'), - common = require(path.resolve('./config/lib/common')), - request = require('request'), - dgram = require('dgram'), - URL = require('url'); - -/** - * doScrape - * @param t - torrent object - */ -module.exports.doScrape = function (t, cb) { - var scrapeInfo = []; - var regex = new RegExp('announce', 'g'); - console.log('torrent_announce = ' + t.torrent_announce); - console.log('info_hash = ' + t.info_hash); - - var url = URL.parse(t.torrent_announce); - var protocol = url.protocol; - var hostname = url.hostname; - var port = url.port; - var path = url.pathname; - var npath = ''; - var info_hash = escape(common.hexToBinary(t.info_hash)); - - var i = path.indexOf('announce'); - if (i >= 0) { - var j = path.indexOf('/', i); - if (j >= 0) { - path = path.slice(0, j); - } - npath = path.replace(regex, 'scrape'); - } else { - npath = '/scrape'; - } - - var scrapeUrl = protocol + '//' + hostname; - scrapeUrl += port ? ':' + port : ''; - scrapeUrl += npath; - - scrapeUrl += '?info_hash=' + info_hash; - console.log('-= scrape =- ' + scrapeUrl); - - if (scrapeUrl.toUpperCase().startsWith('HTTP')) { - doHTTPScrape(); - } else { - doUDPScrape(); - } - - /** - * doHTTPScrape - */ - function doHTTPScrape() { - request(scrapeUrl, {encoding: null}, function (error, response, body) { - //console.log('error:', error); - //console.log('statusCode:', response && response.statusCode); - //console.log('body:', body); - if (error) { - //console.log('-= scrape error =- ' + scrapeUrl); - if (cb) cb(error, null); - } else if (response) { - if (response.statusCode === 200) { - var data = new Buffer(body); - var result = bencoding.decode(data); - - //console.log(result); - //console.log(result.toJSON()); - //console.log(result.vals[0]); - result.keys.forEach(function (k1, idx1) { - //console.log(k1.toString('utf8').toUpperCase() + ' - ' + idx1 + ' - ' + result.vals[idx1]); - if (k1.toString('utf8').toUpperCase() === 'FAILURE REASON') { - //console.log('-= scrape error =- ' + result.vals[idx1].toString('utf8')); - if (cb) cb(result.vals[idx1].toString('utf8'), null); - } else if (k1.toString('utf8').toUpperCase() === 'FILES') { - var val = result.vals[idx1]; - val.keys.forEach(function (k2, idx2) { - //console.log(k2.toString('hex')); - //console.log(val.vals[idx2].toJSON()); - - scrapeInfo.push({ - info_hash: k2.toString('hex'), - data: val.vals[idx2].toJSON() - }); - }); - //console.log(scrapeInfo); - if (scrapeInfo.length > 0) { - scrapeInfo.forEach(function (s) { - console.log(s); - if (s.info_hash === t.info_hash) { - t.update({ - torrent_seeds: s.data.complete, - torrent_finished: s.data.downloaded, - torrent_leechers: s.data.incomplete - }).exec(); - } - }); - if (cb) cb(null, scrapeInfo); - } else { - if (cb) cb('422 result is empty', null); - } - } - }); - } else if (response.statusCode === 403) { - if (cb) cb('403 Forbidden', null); - } - } - - //update torrent last scrape time - t.update({ - last_scrape: Date.now() - }).exec(); - }); - } - - /** - * doUDPScrape - */ - function doUDPScrape() { - var server = dgram.createSocket('udp4'); - var connectionIdHigh = 0x417; - var connectionIdLow = 0x27101980; - var transactionId = Math.floor((Math.random() * 100000) + 1); - var action; - - var ACTION_CONNECT = 0; - var ACTION_ANNOUNCE = 1; - var ACTION_SCRAPE = 2; - var ACTION_ERROR = 3; - - //server.on('listening', function () { - // var address = server.address(); - // console.log('server listening ' + address.address + ':' + address.port); - //}); - - server.on('message', function (msg, rinfo) { - var buf = new Buffer(msg); - - //console.log(rinfo); - action = buf.readUInt32BE(0, 4); - transactionId = buf.readUInt32BE(4, 4); - //console.log('returned action: ' + action); - //console.log('returned transactionId: ' + transactionId); - - if (action === ACTION_CONNECT) { - //console.log('connect response'); - connectionIdHigh = buf.readUInt32BE(8, 4); - connectionIdLow = buf.readUInt32BE(12, 4); - scrapeTorrent(); - } else if (action === ACTION_SCRAPE) { - //console.log('scrape response'); - var _info = {}; - _info.complete = buf.readUInt32BE(8, 4); - _info.downloaded = buf.readUInt32BE(12, 4); - _info.incomplete = buf.readUInt32BE(16, 4); - - scrapeInfo.push({ - info_hash: t.info_hash, - data: _info - }); - //console.log(scrapeInfo); - if (scrapeInfo.length > 0) { - scrapeInfo.forEach(function (s) { - console.log(s); - if (s.info_hash === t.info_hash) { - t.update({ - torrent_seeds: s.data.complete, - torrent_finished: s.data.downloaded, - torrent_leechers: s.data.incomplete - }).exec(); - } - }); - if (cb) cb(null, scrapeInfo); - } else { - if (cb) cb('422 result is empty', null); - } - } else if (action === ACTION_ERROR) { - //console.log('error response'); - if (cb) cb('ACTION_ERROR', null); - } - }); - - server.bind(); - startConnection(); - - //update torrent last scrape time - t.update({ - last_scrape: Date.now() - }).exec(); - - function startConnection() { - var buf = new Buffer(16); - - buf.fill(0); - - buf.writeUInt32BE(connectionIdHigh, 0); - buf.writeUInt32BE(connectionIdLow, 4); - buf.writeUInt32BE(ACTION_CONNECT, 8); - buf.writeUInt32BE(transactionId, 12); - - sendPacket(buf); - } - - function sendPacket(buf) { - server.send(buf, 0, buf.length, port, hostname, function (err, bytes) { - if (err) { - //console.log(err.message); - if (cb) cb(err, null); - } - }); - } - - function scrapeTorrent() { - var buf = new Buffer(36); - - buf.fill(0); - - buf.writeUInt32BE(connectionIdHigh, 0); - buf.writeUInt32BE(connectionIdLow, 4); - buf.writeUInt32BE(ACTION_SCRAPE, 8); - buf.writeUInt32BE(transactionId, 12); - buf.write(info_hash, 16, buf.length, 'hex'); - - // do scrape - sendPacket(buf); - } - } -}; diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 3dbe185a..06ce018c 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -383,7 +383,6 @@ ADMIN_BASIC_REVIEWED: 'Review', ADMIN_BASIC_UPDATE: 'Update torrent info from TMDB', ADMIN_BASIC_DELETE: 'Delete torrent', - ADMIN_BASIC_SCRAPE: 'Scrape torrent status', ADMIN_BASIC_SET_HNR: 'SetHnR', ADMIN_BASIC_UNSET_HNR: 'UnsetHnR', ADMIN_BASIC_SET_VIP: 'SetVIP', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 910bc211..047a8827 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -383,7 +383,6 @@ ADMIN_BASIC_REVIEWED: '通过审核', ADMIN_BASIC_UPDATE: '从 TMDB 更新电影信息', ADMIN_BASIC_DELETE: '删除种子', - ADMIN_BASIC_SCRAPE: '刮削种子状态', ADMIN_BASIC_SET_HNR: '设置HnR', ADMIN_BASIC_UNSET_HNR: '取消HnR', ADMIN_BASIC_SET_VIP: '设置VIP', diff --git a/modules/core/client/controllers/home_torrents.client.controller.js b/modules/core/client/controllers/home_torrents.client.controller.js index 0f76ed6d..66735bd8 100644 --- a/modules/core/client/controllers/home_torrents.client.controller.js +++ b/modules/core/client/controllers/home_torrents.client.controller.js @@ -6,18 +6,17 @@ .controller('HomeTorrentsController', HomeTorrentsController); HomeTorrentsController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'TorrentsService', 'Notification', 'MeanTorrentConfig', - 'getStorageLangService', 'DownloadService', '$timeout', 'localStorageService', 'ScrapeService', 'TorrentGetInfoServices', 'DebugConsoleService', + 'getStorageLangService', 'DownloadService', '$timeout', 'localStorageService', 'TorrentGetInfoServices', 'DebugConsoleService', 'marked']; function HomeTorrentsController($scope, $state, $translate, Authentication, TorrentsService, Notification, MeanTorrentConfig, getStorageLangService, - DownloadService, $timeout, localStorageService, ScrapeService, TorrentGetInfoServices, mtDebug, + DownloadService, $timeout, localStorageService, TorrentGetInfoServices, mtDebug, marked) { var vm = this; vm.DLS = DownloadService; vm.TGI = TorrentGetInfoServices; vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig; vm.appConfig = MeanTorrentConfig.meanTorrentConfig.app; - vm.scrapeConfig = MeanTorrentConfig.meanTorrentConfig.scrapeTorrentStatus; vm.announce = MeanTorrentConfig.meanTorrentConfig.announce; vm.torrentType = MeanTorrentConfig.meanTorrentConfig.torrentType; vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage; @@ -158,11 +157,6 @@ vm.movieTopList = items.rows; vm.initTopOneMovieInfo(); - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.movieTopOne); - ScrapeService.scrapeTorrent(vm.movieTopList); - } } }, function (err) { Notification.error({ @@ -179,10 +173,6 @@ }, function (items) { if (items.rows.length > 0) { vm.movieNewList = items.rows; - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.movieNewList); - } } }, function (err) { Notification.error({ @@ -207,11 +197,6 @@ vm.TVTopList = items.rows; vm.initTopOneTVInfo(); - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.TVTopOne); - ScrapeService.scrapeTorrent(vm.TVTopList); - } } }); @@ -224,10 +209,6 @@ }, function (items) { if (items.rows.length > 0) { vm.TVNewList = items.rows; - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.TVNewList); - } } }); }; @@ -248,11 +229,6 @@ vm.musicTopList = items.rows; vm.initTopOneMusicInfo(); - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.musicTopOne); - ScrapeService.scrapeTorrent(vm.musicTopList); - } } }); @@ -265,10 +241,6 @@ }, function (items) { if (items.rows.length > 0) { vm.musicNewList = items.rows; - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.musicNewList); - } } }); }; @@ -289,11 +261,6 @@ vm.sportsTopList = items.rows; vm.initTopOneSportsInfo(); - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.sportsTopOne); - ScrapeService.scrapeTorrent(vm.sportsTopList); - } } }); @@ -306,10 +273,6 @@ }, function (items) { if (items.rows.length > 0) { vm.sportsNewList = items.rows; - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.sportsNewList); - } } }); }; @@ -330,11 +293,6 @@ vm.varietyTopList = items.rows; vm.initTopOneVarietyInfo(); - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.varietyTopOne); - ScrapeService.scrapeTorrent(vm.varietyTopList); - } } }); @@ -347,10 +305,6 @@ }, function (items) { if (items.rows.length > 0) { vm.varietyNewList = items.rows; - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.varietyNewList); - } } }); }; @@ -371,11 +325,6 @@ vm.pictureTopList = items.rows; vm.initTopOnePictureInfo(); - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.pictureTopOne); - ScrapeService.scrapeTorrent(vm.pictureTopList); - } } }); @@ -388,10 +337,6 @@ }, function (items) { if (items.rows.length > 0) { vm.pictureNewList = items.rows; - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.pictureNewList); - } } }); }; @@ -412,11 +357,6 @@ vm.gameTopList = items.rows; vm.initTopOneGameInfo(); - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.gameTopOne); - ScrapeService.scrapeTorrent(vm.gameTopList); - } } }); @@ -429,10 +369,6 @@ }, function (items) { if (items.rows.length > 0) { vm.gameNewList = items.rows; - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.gameNewList); - } } }); }; @@ -453,11 +389,6 @@ vm.softwareTopList = items.rows; vm.initTopOneSoftwareInfo(); - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.softwareTopOne); - ScrapeService.scrapeTorrent(vm.softwareTopList); - } } }); @@ -470,10 +401,6 @@ }, function (items) { if (items.rows.length > 0) { vm.softwareNewList = items.rows; - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.softwareNewList); - } } }); }; @@ -494,11 +421,6 @@ vm.ebookTopList = items.rows; vm.initTopOneEbookInfo(); - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.ebookTopOne); - ScrapeService.scrapeTorrent(vm.ebookTopList); - } } }); @@ -511,10 +433,6 @@ }, function (items) { if (items.rows.length > 0) { vm.ebookNewList = items.rows; - - if (!vm.announce.privateTorrentCmsMode && vm.scrapeConfig.onTorrentInHome) { - ScrapeService.scrapeTorrent(vm.ebookNewList); - } } }); }; diff --git a/modules/core/client/views/footer.client.view.html b/modules/core/client/views/footer.client.view.html index 00837f02..995afc6e 100644 --- a/modules/core/client/views/footer.client.view.html +++ b/modules/core/client/views/footer.client.view.html @@ -9,8 +9,8 @@
{{'TOTAL_TORRENTSSIZE' | translate}}: {{vm.siteInfo.totalTorrentsSize | bytes}}
{{'TOTAL_SEEDERS' | translate}}: {{vm.siteInfo.totalSeeders}}
{{'TOTAL_LEECHERS' | translate}}: {{vm.siteInfo.totalLeechers}}
-
{{'TOTAL_UPLOADED' | translate}}: {{vm.siteInfo.totalUploaded | bytes}}
-
{{'TOTAL_DOWNLOADED' | translate}}: {{vm.siteInfo.totalDownloaded | bytes}}
+
{{'TOTAL_UPLOADED' | translate}}: {{vm.siteInfo.totalUploaded | bytes}}
+
{{'TOTAL_DOWNLOADED' | translate}}: {{vm.siteInfo.totalDownloaded | bytes}}
{{'TOTAL_FORUMTOPICS' | translate}}: {{vm.siteInfo.totalForumTopics}}
{{'TOTAL_FORUMREPLIES' | translate}}: {{vm.siteInfo.totalForumReplies}}
diff --git a/modules/forums/client/views/topic.client.view.html b/modules/forums/client/views/topic.client.view.html index 50352f16..31896875 100644 --- a/modules/forums/client/views/topic.client.view.html +++ b/modules/forums/client/views/topic.client.view.html @@ -77,7 +77,7 @@ - + ({{vm.topic.user.uploaded | bytes}} {{vm.topic.user.downloaded | bytes}} ) @@ -180,7 +180,7 @@ - + ({{rep.user.uploaded | bytes}} {{rep.user.downloaded | bytes}} ) diff --git a/modules/invitations/client/views/admin/official.client.view.html b/modules/invitations/client/views/admin/official.client.view.html index 806e2d16..1ec26292 100644 --- a/modules/invitations/client/views/admin/official.client.view.html +++ b/modules/invitations/client/views/admin/official.client.view.html @@ -109,27 +109,27 @@