mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(core): Make senderId required for all command messages (#7252)
all commands sent between main instance and workers need to contain a server id to prevent senders from reacting to their own messages, causing loops this PR makes sure all sent messages contain a sender id by default as part of constructing a sending redis client. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
committed by
GitHub
parent
77d6e3fc07
commit
4b014286cf
@@ -1,4 +1,4 @@
|
||||
import type { TEntitlement, TLicenseBlock } from '@n8n_io/license-sdk';
|
||||
import type { TEntitlement, TFeatures, TLicenseBlock } from '@n8n_io/license-sdk';
|
||||
import { LicenseManager } from '@n8n_io/license-sdk';
|
||||
import type { ILogger } from 'n8n-workflow';
|
||||
import { getLogger } from './Logger';
|
||||
@@ -50,6 +50,9 @@ export class License {
|
||||
const saveCertStr = isMainInstance
|
||||
? async (value: TLicenseBlock) => this.saveCertStr(value)
|
||||
: async () => {};
|
||||
const onFeatureChange = isMainInstance
|
||||
? async (features: TFeatures) => this.onFeatureChange(features)
|
||||
: async () => {};
|
||||
|
||||
try {
|
||||
this.manager = new LicenseManager({
|
||||
@@ -64,6 +67,7 @@ export class License {
|
||||
loadCertStr: async () => this.loadCertStr(),
|
||||
saveCertStr,
|
||||
deviceFingerprint: () => instanceId,
|
||||
onFeatureChange,
|
||||
});
|
||||
|
||||
await this.manager.initialize();
|
||||
@@ -89,6 +93,18 @@ export class License {
|
||||
return databaseSettings?.value ?? '';
|
||||
}
|
||||
|
||||
async onFeatureChange(_features: TFeatures): Promise<void> {
|
||||
if (config.getEnv('executions.mode') === 'queue') {
|
||||
if (!this.redisPublisher) {
|
||||
this.logger.debug('Initializing Redis publisher for License Service');
|
||||
this.redisPublisher = await Container.get(RedisService).getPubSubPublisher();
|
||||
}
|
||||
await this.redisPublisher.publishToCommandChannel({
|
||||
command: 'reloadLicense',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async saveCertStr(value: TLicenseBlock): Promise<void> {
|
||||
// if we have an ephemeral license, we don't want to save it to the database
|
||||
if (config.get('license.cert')) return;
|
||||
@@ -100,15 +116,6 @@ export class License {
|
||||
},
|
||||
['key'],
|
||||
);
|
||||
if (config.getEnv('executions.mode') === 'queue') {
|
||||
if (!this.redisPublisher) {
|
||||
this.logger.debug('Initializing Redis publisher for License Service');
|
||||
this.redisPublisher = await Container.get(RedisService).getPubSubPublisher();
|
||||
}
|
||||
await this.redisPublisher.publishToCommandChannel({
|
||||
command: 'reloadLicense',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async activate(activationKey: string): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user