feat(core): meanTorrent support public tracker torrents CMS

This commit is contained in:
OldHawk
2017-07-14 23:37:06 +08:00
parent b153645f2b
commit c9a67c137d
5 changed files with 18 additions and 27 deletions

View File

@@ -193,10 +193,13 @@ such as:
announce_prefix: '[CHD.im].',
admin: 'admin@chd.im',
base_url: 'http://chd.im',
client_black_list_url: 'http://chd.im/client_black_list'
client_black_list_url: 'http://chd.im/client_black_list',
private_torrent_cms: true
},
```
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 `private_torrent_cms` set to `false`, in `private` mode, user can upload and download public tracker torrent files, but these torrent files is can not
used by meanTorrent tracker server.
```javascript
tmdbConfig: {

View File

@@ -17,7 +17,8 @@ module.exports = {
announce_prefix: '[CHD.im].',
admin: 'admin@chd.im',
base_url: 'http://chd.im:3000',
client_black_list_url: 'http://chd.im:3000/client_black_list'
client_black_list_url: 'http://chd.im:3000/client_black_list',
private_torrent_cms: true
},
sign: {
open_signin: true,

View File

@@ -1,4 +1,4 @@
1. The torrent file tracker URL must be: __{{vm.announceConfig.url}}__.
1. If this is a private torrents management system, the torrent file announce URL must be: __{{vm.announceConfig.url}}__.
1. If you selected resource type with `Movie` or `TVSerial`, the torrent TMDB_ID must be `TheMovieDB` resources ID, you can [find the ID
from here]({{vm.tmdbConfig.tmdb_home}}), then the resources detail info can be autoload, if everything looks good, hit submit.
1. Select one or more tags that match the resources, which will play a significant role in your search results.

View File

@@ -1,4 +1,4 @@
1. 种子文件的Tracker地址必须为__{{vm.announceConfig.url}}__.
1. 如果这是私有种子管理系统种子文件的Announce地址必须为__{{vm.announceConfig.url}}__.
1. 如果你选择的资源类型为`电影``电视剧`,种子文件的 TMDB_ID 必须是 `TheMovieDB` 相对应的资源ID号
您可以[从这里找到ID号]({{vm.tmdbConfig.tmdb_home}}). 资源的详细信息,系统会自动载入,如无误可直接提交.
1. 请为资源选择匹配的一个或多个标签,它会在您的搜索结果中发挥重大作用.

View File

@@ -142,11 +142,13 @@ exports.upload = function (req, res) {
message = 'Read torrent file faild';
reject(message);
} else {
if (torrent.metadata.announce !== config.meanTorrentConfig.announce.url) {
console.log(torrent.metadata.announce);
message = 'ANNOUNCE_URL_ERROR';
if (config.meanTorrentConfig.announce.private_torrent_cms) {
if (torrent.metadata.announce !== config.meanTorrentConfig.announce.url) {
console.log(torrent.metadata.announce);
message = 'ANNOUNCE_URL_ERROR';
reject(message);
reject(message);
}
}
torrentinfo = torrent.metadata;
torrentinfo.info_hash = torrent.infoHash();
@@ -305,28 +307,11 @@ exports.download = function (req, res) {
if (exists) {
getTorrentFileData(filePath)
.then(function () {
//var options = {
// root: path.join(__dirname, '../../../../'),
// headers: {
// 'Content-Type': 'application/x-bittorrent',
// 'Content-Disposition': 'attachment; filename=' + config.meanTorrentConfig.announce.announce_prefix + req.torrent.torrent_filename,
// 'Content-Length': stat.size
// }
//};
//res.sendFile(filePath, options);
res.set('Content-Type', 'application/x-bittorrent');
res.set('Content-Disposition', 'attachment; filename=' + config.meanTorrentConfig.announce.announce_prefix + req.torrent.torrent_filename);
res.set('Content-Length', stat.size);
res.send(benc.encode(torrent_data));
//res.writeHead(200, {
// 'Content-Type': 'application/octet-stream',
// 'Content-Disposition': 'attachment; filename=' + config.meanTorrentConfig.announce.announce_prefix + req.torrent.torrent_filename,
// 'Content-Length': stat.size
//});
//fs.createReadStream(filePath).pipe(res);
})
.catch(function (err) {
res.status(422).send(err);
@@ -347,8 +332,10 @@ exports.download = function (req, res) {
message = 'Read torrent file faild';
reject(message);
} else {
var announce = config.meanTorrentConfig.announce.url + '/' + req.user.passkey;
torrent.metadata.announce = announce;
if (config.meanTorrentConfig.announce.private_torrent_cms) {
var announce = config.meanTorrentConfig.announce.url + '/' + req.user.passkey;
torrent.metadata.announce = announce;
}
torrent_data = torrent.metadata;
resolve();
}