фейковое обновление торрентов

This commit is contained in:
Alexey Kasyanchuk 2017-01-21 01:16:40 +03:00
parent 00d4cd79da
commit 2252fcaac4
3 changed files with 42 additions and 22 deletions

View File

@ -1,10 +1,11 @@
module.exports = { module.exports = {
indexer: true, indexer: false,
domain: 'ratsontheboat.org', domain: 'ratsontheboat.org',
httpPort: 8095, httpPort: 8095,
spiderPort: 4445, spiderPort: 4445,
udpTrackersPort: 4446, udpTrackersPort: 4446,
udpTrackersTimeout: 3 * 60 * 1000,
sitemapMaxSize: 25000, sitemapMaxSize: 25000,

View File

@ -147,27 +147,27 @@ app.get('*', function(req, res)
// start // start
function baseRowData(row)
{
return {
hash: row.hash,
name: row.name,
size: row.size,
files: row.files,
filesList: row.filesList,
piecelength: row.piecelength,
added: row.added ? row.added.getTime() : (new Date()).getTime(),
contentType: row.contentType || row.contenttype,
contentCategory: row.contentCategory || row.contentcategory,
seeders: row.seeders,
completed: row.completed,
leechers: row.leechers,
trackersChecked: row.trackersChecked ? row.trackersChecked.getTime() : undefined,
}
}
io.on('connection', function(socket) io.on('connection', function(socket)
{ {
function baseRowData(row)
{
return {
hash: row.hash,
name: row.name,
size: row.size,
files: row.files,
filesList: row.filesList,
piecelength: row.piecelength,
added: row.added ? row.added.getTime() : (new Date()).getTime(),
contentType: row.contentType || row.contenttype,
contentCategory: row.contentCategory || row.contentcategory,
seeders: row.seeders,
completed: row.completed,
leechers: row.leechers,
trackersChecked: row.trackersChecked ? row.trackersChecked.getTime() : undefined,
}
}
socket.on('recentTorrents', function(callback) socket.on('recentTorrents', function(callback)
{ {
if(typeof callback != 'function') if(typeof callback != 'function')
@ -506,4 +506,23 @@ client.on('complete', function (metadata, infohash, rinfo) {
if(config.indexer) { if(config.indexer) {
spider.listen(config.spiderPort) spider.listen(config.spiderPort)
} else {
function showFakeTorrents(page)
{
listenerMysql.query('SELECT * FROM torrents LIMIT ?, 100', [page], function(err, torrents) {
console.log(page)
if(!torrents)
return;
torrents.forEach((torrent, index) => {
setTimeout(() => {
io.sockets.emit('newTorrent', baseRowData(torrent));
updateTorrentTrackers(torrent.hash);
}, 700 * index)
})
setTimeout(()=>showFakeTorrents(torrents.length > 0 ? page + torrents.length : 0), 700 * torrents.length);
});
}
showFakeTorrents(0);
} }

View File

@ -34,7 +34,7 @@ let connectTracker = function(connection) {
// очистка старых соединений // очистка старых соединений
for(transaction in requests) { for(transaction in requests) {
if((new Date).getTime() - requests[transaction].date.getTime() > 3 * 60 * 1000) { if((new Date).getTime() - requests[transaction].date.getTime() > config.udpTrackersTimeout) {
delete requests[transaction]; delete requests[transaction];
} }
} }