ssh tunnel WIP

This commit is contained in:
SPRINX0\prochazka
2025-01-03 16:44:57 +01:00
parent 59788faefd
commit aff282d31e
6 changed files with 29 additions and 8 deletions

View File

@@ -166,7 +166,9 @@ function start() {
if (time - lastPing > 40 * 1000) {
logger.info('Server connection not alive, exiting');
const driver = requireEngineDriver(storedConnection);
await driver.close(dbhan);
if (dbhan) {
await driver.close(dbhan);
}
process.exit(0);
}
}, 10 * 1000);

View File

@@ -7,7 +7,7 @@ const { getLogger, extractErrorLogData, extractErrorMessage } = require('dbgate-
const logger = getLogger('sshProcess');
async function getSshConnection(connection) {
async function getSshConnection(connection, tunnelConfig) {
const sshConfig = {
endHost: connection.sshHost || '',
endPort: connection.sshPort || 22,
@@ -23,6 +23,7 @@ async function getSshConnection(connection) {
: undefined,
skipAutoPrivateKey: true,
noReadline: true,
bindHost: tunnelConfig.fromHost,
};
const sshConn = new SSHConnection(sshConfig);
@@ -31,7 +32,7 @@ async function getSshConnection(connection) {
async function handleStart({ connection, tunnelConfig }) {
try {
const sshConn = await getSshConnection(connection);
const sshConn = await getSshConnection(connection, tunnelConfig);
await sshConn.forward(tunnelConfig);
process.send({