возможность игнорировать dht трафик (опция), больше информации о балансировке
This commit is contained in:
17
bt/spider.js
17
bt/spider.js
@ -109,6 +109,10 @@ class Spider extends Emiter {
|
||||
return
|
||||
}
|
||||
|
||||
if(config.trafficIgnoreDHT && config.trafficMax > 0 && this.trafficSpeed > 0 && this.trafficSpeed > config.trafficMax) {
|
||||
return
|
||||
}
|
||||
|
||||
const {t: tid, a: {id: nid, target: infohash}} = message
|
||||
|
||||
if (tid === undefined || target.length != 20 || nid.length != 20) {
|
||||
@ -130,6 +134,10 @@ class Spider extends Emiter {
|
||||
return
|
||||
}
|
||||
|
||||
if(config.trafficIgnoreDHT && config.trafficMax > 0 && this.trafficSpeed > 0 && this.trafficSpeed > config.trafficMax) {
|
||||
return
|
||||
}
|
||||
|
||||
const {t: tid, a: {id: nid, info_hash: infohash}} = message
|
||||
|
||||
if (tid === undefined || infohash.length != 20 || nid.length != 20) {
|
||||
@ -174,6 +182,14 @@ class Spider extends Emiter {
|
||||
}
|
||||
|
||||
onPingRequest(message, address) {
|
||||
if(this.cpuLimit > 0 && cpuUsage() > this.cpuLimit) {
|
||||
return
|
||||
}
|
||||
|
||||
if(config.trafficIgnoreDHT && config.trafficMax > 0 && this.trafficSpeed > 0 && this.trafficSpeed > config.trafficMax) {
|
||||
return
|
||||
}
|
||||
|
||||
this.send({ t: message.t, y: 'r', r: { id: Node.neighbor(message.a.id, this.table.id) } }, address)
|
||||
}
|
||||
|
||||
@ -224,6 +240,7 @@ class Spider extends Emiter {
|
||||
|
||||
if(config.trafficMax > 0)
|
||||
{
|
||||
trafficDebug('inore dht traffic', config.trafficIgnoreDHT)
|
||||
const path = `/sys/class/net/${config.trafficInterface}/statistics/rx_bytes`
|
||||
if(fs.existsSync(path))
|
||||
{
|
||||
|
Reference in New Issue
Block a user