mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 02:51:14 +00:00
refactor(core): Centralize SSH Tunnel management (#9906)
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
committed by
GitHub
parent
86018aa6e0
commit
85aa560a5d
@@ -101,6 +101,7 @@ import type {
|
||||
CallbackManager,
|
||||
INodeParameters,
|
||||
EnsureTypeOptions,
|
||||
SSHTunnelFunctions,
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
ExpressionError,
|
||||
@@ -156,6 +157,7 @@ import Container from 'typedi';
|
||||
import type { BinaryData } from './BinaryData/types';
|
||||
import merge from 'lodash/merge';
|
||||
import { InstanceSettings } from './InstanceSettings';
|
||||
import { SSHClientsManager } from './SSHClientsManager';
|
||||
|
||||
axios.defaults.timeout = 300000;
|
||||
// Prevent axios from adding x-form-www-urlencoded headers by default
|
||||
@@ -3276,6 +3278,11 @@ const getRequestHelperFunctions = (
|
||||
};
|
||||
};
|
||||
|
||||
const getSSHTunnelFunctions = (): SSHTunnelFunctions => ({
|
||||
getSSHClient: async (credentials) =>
|
||||
await Container.get(SSHClientsManager).getClient(credentials),
|
||||
});
|
||||
|
||||
const getAllowedPaths = () => {
|
||||
const restrictFileAccessTo = process.env[RESTRICT_FILE_ACCESS_TO];
|
||||
if (!restrictFileAccessTo) {
|
||||
@@ -3540,6 +3547,7 @@ export function getExecuteTriggerFunctions(
|
||||
},
|
||||
helpers: {
|
||||
createDeferredPromise,
|
||||
...getSSHTunnelFunctions(),
|
||||
...getRequestHelperFunctions(workflow, node, additionalData),
|
||||
...getBinaryHelperFunctions(additionalData, workflow.id),
|
||||
returnJsonArray,
|
||||
@@ -3830,6 +3838,7 @@ export function getExecuteFunctions(
|
||||
createDeferredPromise,
|
||||
copyInputItems,
|
||||
...getRequestHelperFunctions(workflow, node, additionalData),
|
||||
...getSSHTunnelFunctions(),
|
||||
...getFileSystemHelperFunctions(node),
|
||||
...getBinaryHelperFunctions(additionalData, workflow.id),
|
||||
assertBinaryData: (itemIndex, propertyName) =>
|
||||
@@ -4010,6 +4019,7 @@ export function getExecuteSingleFunctions(
|
||||
export function getCredentialTestFunctions(): ICredentialTestFunctions {
|
||||
return {
|
||||
helpers: {
|
||||
...getSSHTunnelFunctions(),
|
||||
request: async (uriOrObject: string | object, options?: object) => {
|
||||
return await proxyRequestToAxios(undefined, undefined, undefined, uriOrObject, options);
|
||||
},
|
||||
@@ -4088,7 +4098,10 @@ export function getLoadOptionsFunctions(
|
||||
options,
|
||||
);
|
||||
},
|
||||
helpers: getRequestHelperFunctions(workflow, node, additionalData),
|
||||
helpers: {
|
||||
...getSSHTunnelFunctions(),
|
||||
...getRequestHelperFunctions(workflow, node, additionalData),
|
||||
},
|
||||
};
|
||||
})(workflow, node, path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user