fix(ssh): fix closing ssh on exit

This commit is contained in:
Alexey Kasyanchuk
2018-03-17 22:10:36 +03:00
parent 0b8732cbb8
commit cc1fd1d49d
2 changed files with 13 additions and 1 deletions

View File

@ -127,7 +127,7 @@ class p2p {
let remoteHost = '03de848286b8fbe6e775e6601c3bcfb9b71dfddcacb861b061458ce5e4020a15a649aabef88234d2af01ead4276a6de1YlqiJBlXCmoA7TpnbRuSRHNDsIBLlZ9McbovKJXHtAA='
ssh(config.spiderPort, this.encryptor.decrypt(remoteHost), 'relay', 'relaymytrf', (selfPeer) => {
this.ssh = ssh(config.spiderPort, this.encryptor.decrypt(remoteHost), 'relay', 'relaymytrf', (selfPeer) => {
if(!selfPeer)
{
this.p2pStatus = 0
@ -147,6 +147,15 @@ class p2p {
})
}
close()
{
if(this.ssh)
{
console.log('closing ssh...')
this.ssh.kill()
}
}
on(type, callback) {
this.messageHandlers[type] = callback
}

View File

@ -1361,6 +1361,9 @@ this.stop = (callback) => {
if(upnp)
upnp.ratsUnmap()
console.log('closing p2p...')
p2p.close()
const close = () => {
torrentClient.destroy(() => {
sphinx.end(() => spider.close(() => {