n8n-core 1.49.0 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE_EE.md +27 -0
- package/dist/NodeExecuteFunctions.js +11 -1
- package/dist/NodeExecuteFunctions.js.map +1 -1
- package/dist/SSHClientsManager.d.ts +12 -0
- package/dist/SSHClientsManager.js +82 -0
- package/dist/SSHClientsManager.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -1
- package/package.json +17 -14
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SSHClientsManager = void 0;
|
|
13
|
+
const typedi_1 = require("typedi");
|
|
14
|
+
const ssh2_1 = require("ssh2");
|
|
15
|
+
const node_crypto_1 = require("node:crypto");
|
|
16
|
+
let SSHClientsManager = class SSHClientsManager {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.clients = new Map();
|
|
19
|
+
process.on('exit', () => this.onShutdown());
|
|
20
|
+
if (process.env.NODE_ENV === 'test')
|
|
21
|
+
return;
|
|
22
|
+
setInterval(() => this.cleanupStaleConnections(), 60 * 1000);
|
|
23
|
+
}
|
|
24
|
+
async getClient(credentials) {
|
|
25
|
+
var _a;
|
|
26
|
+
const { sshAuthenticateWith, sshHost, sshPort, sshUser } = credentials;
|
|
27
|
+
const sshConfig = {
|
|
28
|
+
host: sshHost,
|
|
29
|
+
port: sshPort,
|
|
30
|
+
username: sshUser,
|
|
31
|
+
...(sshAuthenticateWith === 'password'
|
|
32
|
+
? { password: credentials.sshPassword }
|
|
33
|
+
: {
|
|
34
|
+
privateKey: credentials.privateKey,
|
|
35
|
+
passphrase: (_a = credentials.passphrase) !== null && _a !== void 0 ? _a : undefined,
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
const clientHash = (0, node_crypto_1.createHash)('sha1').update(JSON.stringify(sshConfig)).digest('base64');
|
|
39
|
+
const existing = this.clients.get(clientHash);
|
|
40
|
+
if (existing) {
|
|
41
|
+
existing.lastUsed = new Date();
|
|
42
|
+
return existing.client;
|
|
43
|
+
}
|
|
44
|
+
return await new Promise((resolve, reject) => {
|
|
45
|
+
const sshClient = new ssh2_1.Client();
|
|
46
|
+
sshClient.once('error', reject);
|
|
47
|
+
sshClient.once('ready', () => {
|
|
48
|
+
sshClient.off('error', reject);
|
|
49
|
+
sshClient.once('close', () => this.clients.delete(clientHash));
|
|
50
|
+
this.clients.set(clientHash, {
|
|
51
|
+
client: sshClient,
|
|
52
|
+
lastUsed: new Date(),
|
|
53
|
+
});
|
|
54
|
+
resolve(sshClient);
|
|
55
|
+
});
|
|
56
|
+
sshClient.connect(sshConfig);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
onShutdown() {
|
|
60
|
+
for (const { client } of this.clients.values()) {
|
|
61
|
+
client.end();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
cleanupStaleConnections() {
|
|
65
|
+
const { clients } = this;
|
|
66
|
+
if (clients.size === 0)
|
|
67
|
+
return;
|
|
68
|
+
const now = Date.now();
|
|
69
|
+
for (const [hash, { client, lastUsed }] of clients.entries()) {
|
|
70
|
+
if (now - lastUsed.getTime() > 5 * 60 * 1000) {
|
|
71
|
+
client.end();
|
|
72
|
+
clients.delete(hash);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.SSHClientsManager = SSHClientsManager;
|
|
78
|
+
exports.SSHClientsManager = SSHClientsManager = __decorate([
|
|
79
|
+
(0, typedi_1.Service)(),
|
|
80
|
+
__metadata("design:paramtypes", [])
|
|
81
|
+
], SSHClientsManager);
|
|
82
|
+
//# sourceMappingURL=SSHClientsManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSHClientsManager.js","sourceRoot":"","sources":["../src/SSHClientsManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAiC;AACjC,+BAAkD;AAClD,6CAAyC;AAIlC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAG7B;QAFS,YAAO,GAAG,IAAI,GAAG,EAA8C,CAAC;QAIxE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAE5C,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM;YAAE,OAAO;QAG5C,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,WAA2B;;QAC1C,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;QACvE,MAAM,SAAS,GAAkB;YAChC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,OAAO;YACjB,GAAG,CAAC,mBAAmB,KAAK,UAAU;gBACrC,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,WAAW,EAAE;gBACvC,CAAC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