feat(config): p2p enable/disable
This commit is contained in:
@ -101,9 +101,11 @@ class App extends Component {
|
||||
render() {
|
||||
return (
|
||||
<MuiThemeProvider>
|
||||
<PagesPie />
|
||||
<div className='fs0-85 pad0-75' style={{position: 'fixed', bottom: 0, left: 0, color: window.peers > 0 ? 'green' : 'grey'}}>
|
||||
rats peers: {window.peers} {window.peers > 0 ? ' (p2p rats search enabled)' : ' (p2p rats search not available at this moment)'}
|
||||
<div>
|
||||
<PagesPie />
|
||||
<div className='fs0-85 pad0-75' style={{position: 'fixed', bottom: 0, left: 0, color: window.peers > 0 ? 'green' : 'grey'}}>
|
||||
rats peers: {window.peers} {window.peers > 0 ? ' (p2p rats search enabled)' : ' (p2p rats search not available at this moment)'}
|
||||
</div>
|
||||
</div>
|
||||
</MuiThemeProvider>
|
||||
);
|
||||
|
@ -8,7 +8,6 @@ const Token = require('./token')
|
||||
const cpuUsage = require('./cpu-usage')
|
||||
const config = require('../config')
|
||||
const fs = require('fs')
|
||||
const crypto = require('crypto')
|
||||
|
||||
const _debug = require('debug')
|
||||
const cpuDebug = _debug('spider:cpu')
|
||||
@ -52,7 +51,7 @@ class Spider extends Emiter {
|
||||
this.cpuLimit = config.spider.cpuLimit;
|
||||
this.cpuInterval = config.spider.cpuInterval;
|
||||
|
||||
this.announceHashes = [crypto.createHash('sha1').update('degrats-v1').digest()]
|
||||
this.announceHashes = []
|
||||
}
|
||||
|
||||
send(message, address) {
|
||||
@ -333,16 +332,12 @@ class Spider extends Emiter {
|
||||
}
|
||||
}
|
||||
|
||||
this.announceSearchInterval = setInterval(() => this.getPeersRequest(this.announceHashes[0]), 2000)
|
||||
|
||||
/*
|
||||
setInterval(() => {
|
||||
for(const address of this.table.nodes)
|
||||
this.announceSearchInterval = setInterval(() => {
|
||||
for(const hash of this.announceHashes)
|
||||
{
|
||||
this.announcePeer(this.announcePeer[0], null, address)
|
||||
this.getPeersRequest(hash)
|
||||
}
|
||||
}, 3000)
|
||||
*/
|
||||
}
|
||||
|
||||
close(callback)
|
||||
|
@ -5,6 +5,7 @@ const mysql = require('mysql');
|
||||
const getPeersStatisticUDP = require('./bt/udp-tracker-request')
|
||||
const net = require('net')
|
||||
const JsonSocket = require('json-socket')
|
||||
const crypto = require('crypto')
|
||||
|
||||
//var express = require('express');
|
||||
//var app = express();
|
||||
@ -630,6 +631,15 @@ tcpServer.on('connection', (socket) => {
|
||||
if(option in config)
|
||||
config[option] = options[option]
|
||||
}
|
||||
|
||||
if(config.p2p)
|
||||
{
|
||||
spider.announceHashes = [crypto.createHash('sha1').update('degrats-v1').digest()]
|
||||
}
|
||||
else
|
||||
{
|
||||
spider.announceHashes = []
|
||||
}
|
||||
|
||||
if(typeof callback === 'function')
|
||||
callback(true)
|
||||
@ -1157,6 +1167,10 @@ function hideFakeTorrents()
|
||||
|
||||
if(config.indexer) {
|
||||
spider.listen(config.spiderPort)
|
||||
if(config.p2p)
|
||||
{
|
||||
spider.announceHashes = [crypto.createHash('sha1').update('degrats-v1').digest()]
|
||||
}
|
||||
} else {
|
||||
// showFakeTorrents();
|
||||
}
|
||||
|
Reference in New Issue
Block a user