ssh tunnel - reuse SSH connection + local port for multiple DB connections

This commit is contained in:
Jan Prochazka
2021-02-13 07:47:55 +01:00
parent 728ca72cc1
commit 114dc0b543
15 changed files with 172 additions and 32 deletions

View File

@@ -3,6 +3,7 @@ const socket = require('../utility/socket');
const { fork } = require('child_process');
const _ = require('lodash');
const AsyncLock = require('async-lock');
const { handleProcessCommunication } = require('../utility/processComm');
const lock = new AsyncLock();
module.exports = {
@@ -43,8 +44,10 @@ module.exports = {
this.opened.push(newOpened);
delete this.closed[conid];
socket.emitChanged(`server-status-changed`);
// @ts-ignore
subprocess.on('message', ({ msgtype, ...message }) => {
subprocess.on('message', message => {
// @ts-ignore
const { msgtype } = message;
if (handleProcessCommunication(message, subprocess)) return;
if (newOpened.disconnected) return;
this[`handle_${msgtype}`](conid, message);
});