SYNC: private cloud UX + fixes

This commit is contained in:
SPRINX0\prochazka
2025-06-20 13:45:32 +02:00
committed by Diflow
parent f2af38da4c
commit d668128a34
4 changed files with 59 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ const { getSshTunnelProxy } = require('./sshTunnelProxy');
const platformInfo = require('../utility/platformInfo');
const connections = require('../controllers/connections');
const _ = require('lodash');
const { getCloudFolderEncryptor } = require('./cloudIntf');
async function loadConnection(driver, storedConnection, connectionMode) {
const { allowShellConnection, allowConnectionFromEnvVariables } = platformInfo;
@@ -88,13 +89,31 @@ async function extractConnectionSslParams(connection) {
return ssl;
}
async function decryptCloudConnection(connection) {
const m = connection?._id?.match(/^cloud\:\/\/(.+)\/(.+)$/);
if (!m) {
throw new Error('Invalid cloud connection ID format');
}
const folid = m[1];
const cntid = m[2];
const folderEncryptor = await getCloudFolderEncryptor(folid);
return decryptConnection(connection, folderEncryptor);
}
async function connectUtility(driver, storedConnection, connectionMode, additionalOptions = null) {
const connectionLoaded = await loadConnection(driver, storedConnection, connectionMode);
const connection = {
database: connectionLoaded.defaultDatabase,
...decryptConnection(connectionLoaded),
};
const connection = connectionLoaded?._id?.startsWith('cloud://')
? {
database: connectionLoaded.defaultDatabase,
...(await decryptCloudConnection(connectionLoaded)),
}
: {
database: connectionLoaded.defaultDatabase,
...decryptConnection(connectionLoaded),
};
if (!connection.port && driver.defaultPort) {
connection.port = driver.defaultPort.toString();