mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Filter plugin messages forwarded to links
Drop events forwarded to a slave or instance that does not have the plugin the event is defined in. Reject requests for the same reason.
This commit is contained in:
1 parent
ca2839594e
commit
a194508f52
8 files changed
+108
-37
No files matched your search
+8
-1
@@ -242,7 +242,10 @@ class BaseMasterPlugin {
|
||||
*/
|
||||
broadcastEventToSlaves(event, data={}) {
|
||||
for (let slaveConnection of this.master.slaveConnections.values()) {
|
||||
if (!slaveConnection.connector.closing) {
|
||||
if (
|
||||
!slaveConnection.connector.closing
|
||||
&& (!event.plugin || slaveConnection.plugins.has(event.plugin))
|
||||
) {
|
||||
event.send(slaveConnection, data);
|
||||
}
|
||||
}
|
||||
@@ -300,6 +303,10 @@ async function loadPluginInfos(baseDir) {
|
||||
function attachPluginMessages(link, pluginInfo, plugin) {
|
||||
let messageDefinitions = pluginInfo.messages || [];
|
||||
for (let [name, messageFormat] of Object.entries(messageDefinitions)) {
|
||||
if (messageFormat.plugin !== pluginInfo.name) {
|
||||
throw new Error(`Type of ${name} message must start with "${pluginInfo.name}:"`);
|
||||
}
|
||||
|
||||
let handler = name + messageFormat.constructor.name + 'Handler';
|
||||
if (plugin === null || !plugin[handler]) {
|
||||
messageFormat.attach(link);
|
||||
|
||||
Reference in new issue
Block a user