feat(p2p): app version on p2p

This commit is contained in:
Alexey Kasyanchuk 2018-03-28 23:35:58 +03:00
parent 9224da808e
commit 6a63bc626d
3 changed files with 6 additions and 2 deletions

View File

@ -362,7 +362,7 @@ app.on("ready", () => {
}
callback.apply(null, arg)
})
}, app.getPath("userData"))
}, app.getPath("userData"), app.getVersion())
})
});

View File

@ -12,6 +12,7 @@ class p2p {
externalPeers = []
size = 0
p2pStatus = 0
version = '0'
constructor(send = () => {})
{
@ -53,6 +54,7 @@ class p2p {
callback({
protocol: 'rats',
version: this.version,
peers: this.peersList().slice(0, 4).map(peer => ({address: peer.address, port: peer.port}))
})
@ -224,6 +226,7 @@ class p2p {
emit('protocol', {
protocol: 'rats',
port: config.spiderPort,
version: this.version,
peers: this.peersList().slice(0, 4).map(peer => ({address: peer.address, port: peer.port})).concat(this.externalPeers) // also add external peers
}, (data) => {
if(!data || data.protocol != 'rats')

View File

@ -37,7 +37,7 @@ const torrentClient = require('./torrentClient')
//server.listen(config.httpPort);
//console.log('Listening web server on', config.httpPort, 'port')
module.exports = function (send, recive, dataDirectory)
module.exports = function (send, recive, dataDirectory, version)
{
let torrentsId = 1;
@ -253,6 +253,7 @@ function baseRowData(row)
}
const p2p = new P2PServer(send)
p2p.version = version
p2p.encryptor = encryptor
p2p.listen()
// load initial peers