From 00d4cd79dad4f29d668e52f07b042c5163dc7e03 Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Sat, 21 Jan 2017 00:43:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BF=D0=B0=D1=83=D1=87=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.js | 6 ++++++ index.js | 4 +++- lib/spider.js | 7 ++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config.js b/config.js index 230b6ee..8bf9be1 100644 --- a/config.js +++ b/config.js @@ -21,4 +21,10 @@ module.exports = { database : 'btsearch', connectionLimit: 40 }, + + spider: { + walkInterval: 5, + cpuLimit: 0, + cpuInterval: 10, + }, } diff --git a/index.js b/index.js index f63949b..dcb4d1b 100644 --- a/index.js +++ b/index.js @@ -504,4 +504,6 @@ client.on('complete', function (metadata, infohash, rinfo) { // spider.on('nodes', (nodes)=>console.log('foundNodes')) -spider.listen(config.spiderPort) \ No newline at end of file +if(config.indexer) { + spider.listen(config.spiderPort) +} \ No newline at end of file diff --git a/lib/spider.js b/lib/spider.js index aa6826a..bcaec0c 100644 --- a/lib/spider.js +++ b/lib/spider.js @@ -6,6 +6,7 @@ const bencode = require('bencode') const {Table, Node} = require('./table') const Token = require('./token') const cpuUsage = require('./cpu-usage') +const config = require('../config') const bootstraps = [{ address: 'router.bittorrent.com', @@ -40,9 +41,9 @@ class Spider extends Emiter { this.client = client this.ignore = false; // ignore all requests - this.walkInterval = 5; - this.cpuLimit = 0; - this.cpuInterval = 10; + this.walkInterval = config.spider.walkInterval; + this.cpuLimit = config.spider.cpuLimit; + this.cpuInterval = config.spider.cpuInterval; } send(message, address) {