разбиение карты
This commit is contained in:
parent
072a40d3e1
commit
56da04ecd1
27
index.js
27
index.js
@ -88,8 +88,30 @@ handleListenerDisconnect();
|
|||||||
|
|
||||||
app.use(express.static('build', {index: false}));
|
app.use(express.static('build', {index: false}));
|
||||||
|
|
||||||
|
const sitemapSize = 30000;
|
||||||
app.get('/sitemap.xml', function(req, res) {
|
app.get('/sitemap.xml', function(req, res) {
|
||||||
socketMysql.query('SELECT hash FROM `torrents`', function (error, rows, fields) {
|
socketMysql.query('SELECT count(*) as cnt FROM `torrents`', function (error, rows, fields) {
|
||||||
|
if(!rows) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let urls = []
|
||||||
|
for(let i = 0; i < Math.ceil(rows[0].cnt / sitemapSize); i++)
|
||||||
|
urls.push(`http://${domain}/sitemap${i+1}.xml`);
|
||||||
|
|
||||||
|
res.header('Content-Type', 'application/xml');
|
||||||
|
res.send( sm.buildSitemapIndex({
|
||||||
|
urls
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/sitemap:id.xml', function(req, res) {
|
||||||
|
if(req.params.id < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let page = (req.params.id - 1) * sitemapSize
|
||||||
|
|
||||||
|
socketMysql.query('SELECT hash FROM `torrents` LIMIT ?, ?', [page, sitemapSize], function (error, rows, fields) {
|
||||||
if(!rows) {
|
if(!rows) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -111,6 +133,7 @@ app.get('/sitemap.xml', function(req, res) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.get('*', function(req, res)
|
app.get('*', function(req, res)
|
||||||
{
|
{
|
||||||
if(typeof req.query['_escaped_fragment_'] != 'undefined')
|
if(typeof req.query['_escaped_fragment_'] != 'undefined')
|
||||||
@ -477,4 +500,4 @@ client.on('complete', function (metadata, infohash, rinfo) {
|
|||||||
|
|
||||||
// spider.on('nodes', (nodes)=>console.log('foundNodes'))
|
// spider.on('nodes', (nodes)=>console.log('foundNodes'))
|
||||||
|
|
||||||
spider.listen(4445)
|
//spider.listen(4445)
|
Loading…
Reference in New Issue
Block a user