Rename Master to Controller

The role of the master server as the party controlling every part of the
cluster is not well reflected in its name and has caused confusion among
users on several occasions.  Rename master to controller to better
reflects its role.
This commit is contained in:
Hornwitser committed 2023-02-22 15:30:51 +01:00
1 parent 6ae4c8ef46
commit 70ad295a89
119 files changed
+1394 -1376

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
# Common Library for Clusterio
This package contains functionality shared between master, slave, ctl and/or plugins of Clusterio.
This package contains functionality shared between controller, slave, ctl and/or plugins of Clusterio.
See [the Clusterio repository](https://github.com/clusterio/clusterio) for more information on Clusterio.
+4 -4
View File
@@ -140,7 +140,7 @@ class CommandTree {
* Resolves a string with either an slave name or an id into an integer with
* the slave ID.
*
* @param {module:lib/link.Link} client - link to master server to query slave on.
* @param {module:lib/link.Link} client - link to controller to query slave on.
* @param {string} slaveName - string with name or id of slave.
* @returns {Promise<number>} slave ID.
* @static
@@ -172,7 +172,7 @@ async function resolveSlave(client, slaveName) {
* Resolves a string with either an instance name or an id into an integer
* with the instance ID.
*
* @param {module:lib/link.Link} client - link to master server to query instance on.
* @param {module:lib/link.Link} client - link to controller to query instance on.
* @param {string} instanceName - string with name or id of instance.
* @returns {Promise<number>} instance ID.
* @static
@@ -205,7 +205,7 @@ async function resolveInstance(client, instanceName) {
* with the mod pack ID.
*
* @param {module:lib/link.Link} client -
* link to master server to query mod pack on.
* link to controller to query mod pack on.
* @param {string} modPackName - string with name or id of mod pack.
* @returns {Promise<number>} mod pack ID.
* @static
@@ -237,7 +237,7 @@ async function resolveModPack(client, modPackName) {
* Resolves a string with either a role name or an id into an object
* representing the role.
*
* @param {module:lib/link.Link} client - link to master server to query role on.
* @param {module:lib/link.Link} client - link to controller to query role on.
* @param {string} roleName - string with name or id of role.
* @returns {Promise<object>} Role info.
* @static
+57 -57
View File
@@ -5,35 +5,35 @@ const classes = require("./classes");
/**
* Master config group for {@link module:lib/config.MasterConfig}
* Controller config group for {@link module:lib/config.ControllerConfig}
* @extends module:lib/config.ConfigGroup
* @memberof module:lib/config
*/
class MasterGroup extends classes.ConfigGroup { }
MasterGroup.defaultAccess = ["master", "slave", "control"];
MasterGroup.groupName = "master";
MasterGroup.define({
class ControllerGroup extends classes.ConfigGroup { }
ControllerGroup.defaultAccess = ["controller", "slave", "control"];
ControllerGroup.groupName = "controller";
ControllerGroup.define({
name: "name",
title: "Name",
description: "Name of the cluster.",
type: "string",
initial_value: "Your Cluster",
});
MasterGroup.define({
ControllerGroup.define({
name: "mods_directory",
title: "Mods Directory",
description: "Path to directory where mods shared with the cluster are stored.",
type: "string",
initial_value: "mods",
});
MasterGroup.define({
ControllerGroup.define({
name: "database_directory",
title: "Database directory",
description: "Directory where item and configuration data is stored.",
type: "string",
initial_value: "database",
});
MasterGroup.define({
ControllerGroup.define({
name: "http_port",
title: "HTTP Port",
description: "Port to listen for HTTP connections on, set to null to not listen for HTTP connections.",
@@ -42,7 +42,7 @@ MasterGroup.define({
optional: true,
initial_value: 8080,
});
MasterGroup.define({
ControllerGroup.define({
name: "https_port",
title: "HTTPS Port",
description: "Port to listen for HTTPS connection on, set to null to not listen for HTTPS connections.",
@@ -50,7 +50,7 @@ MasterGroup.define({
type: "number",
optional: true,
});
MasterGroup.define({
ControllerGroup.define({
name: "bind_address",
title: "Bind Address",
description: "IP address to bind the HTTP and HTTPS ports on.",
@@ -58,14 +58,14 @@ MasterGroup.define({
type: "string",
optional: true,
});
MasterGroup.define({
ControllerGroup.define({
name: "external_address",
title: "External Address",
description: "Public facing address the master server is hosted on.",
description: "Public facing address the controller is hosted on.",
type: "string",
optional: true,
});
MasterGroup.define({
ControllerGroup.define({
name: "tls_certificate",
title: "TLS Certificate",
description: "Path to the certificate to use for HTTPS.",
@@ -73,7 +73,7 @@ MasterGroup.define({
type: "string",
optional: true,
});
MasterGroup.define({
ControllerGroup.define({
name: "tls_private_key",
title: "TLS Private Key",
description: "Path to the private key to use for HTTPS.",
@@ -81,10 +81,10 @@ MasterGroup.define({
type: "string",
optional: true,
});
MasterGroup.define({
access: ["master"],
ControllerGroup.define({
access: ["controller"],
name: "auth_secret",
title: "Master Authentication Secret",
title: "Controller Authentication Secret",
description:
"Secret used to generate and verify authentication tokens. " +
"Should be a long string of random letters and numbers. " +
@@ -93,42 +93,42 @@ MasterGroup.define({
type: "string",
optional: true,
});
MasterGroup.define({
ControllerGroup.define({
name: "heartbeat_interval",
title: "Heartbeat Interval",
description: "Interval heartbeats are sent out on WebSocket connections.",
type: "number",
initial_value: 15,
});
MasterGroup.define({
ControllerGroup.define({
name: "session_timeout",
title: "Session Timeout",
description: "Time in seconds before giving up resuming a dropped WebSocket session.",
type: "number",
initial_value: 60,
});
MasterGroup.define({
ControllerGroup.define({
name: "metrics_timeout",
title: "Metrics Timeout",
description: "Timeout in seconds for metrics gathering from slaves.",
type: "number",
initial_value: 8,
});
MasterGroup.define({
ControllerGroup.define({
name: "proxy_stream_timeout",
title: "Proxy Stream Timeout",
description: "Timeout in seconds for proxy streams to start flowing.",
type: "number",
initial_value: 15,
});
MasterGroup.define({
ControllerGroup.define({
name: "default_mod_pack_id",
title: "Default Mod Pack",
description: "Mod pack used by default for instances.",
type: "number",
optional: true,
});
MasterGroup.define({
ControllerGroup.define({
name: "default_role_id",
title: "Default role",
description: "ID of role assigned by default to new users.",
@@ -136,15 +136,15 @@ MasterGroup.define({
optional: true,
initial_value: 1,
});
MasterGroup.finalize();
ControllerGroup.finalize();
/**
* Master Config class
* Controller Config class
* @extends module:lib/config.Config
* @memberof module:lib/config
*/
class MasterConfig extends classes.Config { }
MasterConfig.registerGroup(MasterGroup);
class ControllerConfig extends classes.Config { }
ControllerConfig.registerGroup(ControllerGroup);
/**
@@ -153,7 +153,7 @@ MasterConfig.registerGroup(MasterGroup);
* @memberof module:lib/config
*/
class SlaveGroup extends classes.ConfigGroup {}
SlaveGroup.defaultAccess = ["master", "slave", "control"];
SlaveGroup.defaultAccess = ["controller", "slave", "control"];
SlaveGroup.groupName = "slave";
SlaveGroup.define({
name: "name",
@@ -183,7 +183,7 @@ SlaveGroup.define({
SlaveGroup.define({
name: "mods_directory_is_shared",
title: "Mods Directory is Shared",
description: "True if the mods directory is shared with the master server.",
description: "True if the mods directory is shared with the controller.",
type: "boolean",
initial_value: true,
});
@@ -195,22 +195,22 @@ SlaveGroup.define({
initial_value: "instances",
});
SlaveGroup.define({
name: "master_url",
description: "URL to connect to the master server at",
name: "controller_url",
description: "URL to connect to the controller at",
restartRequired: true,
type: "string",
initial_value: "http://localhost:8080/",
});
SlaveGroup.define({
name: "master_token",
description: "Token to authenticate to master server with.",
name: "controller_token",
description: "Token to authenticate to controller with.",
restartRequired: true,
type: "string",
initial_value: "enter token here",
});
SlaveGroup.define({
name: "tls_ca",
description: "Path to Certificate Authority to validate TLS connection to master against.",
description: "Path to Certificate Authority to validate TLS connection to controller against.",
restartRequired: true,
type: "string",
optional: true,
@@ -245,7 +245,7 @@ SlaveConfig.registerGroup(SlaveGroup);
* @memberof module:lib/config
*/
class InstanceGroup extends classes.ConfigGroup { }
InstanceGroup.defaultAccess = ["master", "slave", "control"];
InstanceGroup.defaultAccess = ["controller", "slave", "control"];
InstanceGroup.groupName = "instance";
InstanceGroup.define({
name: "name",
@@ -277,7 +277,7 @@ InstanceGroup.finalize();
* @memberof module:lib/config
*/
class FactorioGroup extends classes.ConfigGroup { }
FactorioGroup.defaultAccess = ["master", "slave", "control"];
FactorioGroup.defaultAccess = ["controller", "slave", "control"];
FactorioGroup.groupName = "factorio";
FactorioGroup.define({
name: "version",
@@ -353,7 +353,7 @@ FactorioGroup.define({
"require_user_verification", "tags", "visibility",
],
type: "object",
initial_value: {}, // See create instance handler in master.
initial_value: {}, // See create instance handler in controller.
});
FactorioGroup.define({
name: "verbose_logging",
@@ -371,19 +371,19 @@ FactorioGroup.define({
});
FactorioGroup.define({
name: "sync_adminlist",
description: "Synchronize adminlist with master server",
description: "Synchronize adminlist with controller",
type: "boolean",
initial_value: true,
});
FactorioGroup.define({
name: "sync_whitelist",
description: "Synchronize whitelist with master server",
description: "Synchronize whitelist with controller",
type: "boolean",
initial_value: true,
});
FactorioGroup.define({
name: "sync_banlist",
description: "Synchronize banlist with master server",
description: "Synchronize banlist with controller",
type: "boolean",
initial_value: true,
});
@@ -415,20 +415,20 @@ class ControlGroup extends classes.ConfigGroup {}
ControlGroup.defaultAccess = ["control"];
ControlGroup.groupName = "control";
ControlGroup.define({
name: "master_url",
description: "URL to connect to the master server at",
name: "controller_url",
description: "URL to connect to the controller at",
type: "string",
optional: true,
});
ControlGroup.define({
name: "master_token",
description: "Token to authenticate to master server with.",
name: "controller_token",
description: "Token to authenticate to controller with.",
type: "string",
optional: true,
});
ControlGroup.define({
name: "tls_ca",
description: "Path to Certificate Authority to validate TLS connection to master against.",
description: "Path to Certificate Authority to validate TLS connection to controller against.",
type: "string",
optional: true,
});
@@ -472,16 +472,16 @@ function validateGroup(pluginInfo, groupName) {
*/
function registerPluginConfigGroups(pluginInfos) {
for (let pluginInfo of pluginInfos) {
if (pluginInfo.MasterConfigGroup) {
validateGroup(pluginInfo, "MasterConfigGroup");
MasterConfig.registerGroup(pluginInfo.MasterConfigGroup);
if (pluginInfo.ControllerConfigGroup) {
validateGroup(pluginInfo, "ControllerConfigGroup");
ControllerConfig.registerGroup(pluginInfo.ControllerConfigGroup);
} else {
class MasterConfigGroup extends classes.PluginConfigGroup { }
MasterConfigGroup.defaultAccess = ["master", "slave", "control"];
MasterConfigGroup.groupName = pluginInfo.name;
MasterConfigGroup.finalize();
MasterConfig.registerGroup(MasterConfigGroup);
class ControllerConfigGroup extends classes.PluginConfigGroup { }
ControllerConfigGroup.defaultAccess = ["controller", "slave", "control"];
ControllerConfigGroup.groupName = pluginInfo.name;
ControllerConfigGroup.finalize();
ControllerConfig.registerGroup(ControllerConfigGroup);
}
if (pluginInfo.instanceEntrypoint) {
@@ -491,7 +491,7 @@ function registerPluginConfigGroups(pluginInfos) {
} else {
class InstanceConfigGroup extends classes.PluginConfigGroup { }
InstanceConfigGroup.defaultAccess = ["master", "slave", "control"];
InstanceConfigGroup.defaultAccess = ["controller", "slave", "control"];
InstanceConfigGroup.groupName = pluginInfo.name;
InstanceConfigGroup.finalize();
InstanceConfig.registerGroup(InstanceConfigGroup);
@@ -506,20 +506,20 @@ function registerPluginConfigGroups(pluginInfos) {
* @memberof module:lib/config
*/
function finalizeConfigs() {
MasterConfig.finalize();
ControllerConfig.finalize();
SlaveConfig.finalize();
InstanceConfig.finalize();
ControlConfig.finalize();
}
module.exports = {
MasterGroup,
ControllerGroup,
SlaveGroup,
InstanceGroup,
FactorioGroup,
ControlGroup,
MasterConfig,
ControllerConfig,
SlaveConfig,
InstanceConfig,
ControlConfig,
+1 -1
View File
@@ -11,7 +11,7 @@ const { integerModVersion, integerFactorioVersion, modVersionRegExp } = require(
/**
* Info about a mod available on the master server.
* Info about a mod available on the controller.
*
* See https://wiki.factorio.com/Tutorial:Mod_structure#info.json for
* details of the invidiual fields sourced from info.json.
+2 -2
View File
@@ -1,5 +1,5 @@
/**
* Implementation of master databases
* Implementation of controller databases
*
* @module lib/database
* @author Hornwitser
@@ -159,7 +159,7 @@ function checkCount(count) {
/**
* Item database
*
* Stores counts of items for the master server. Items that have not been
* Stores counts of items for the controller. Items that have not been
* stored in the database are treated as having a stored count of zero. When
* serialized the database discards entries with a zero counts, and when
* deserialized the content is verified.
+6 -6
View File
@@ -179,7 +179,7 @@ class WebSocketBaseConnector extends events.EventEmitter {
}
/**
* Connector for master server clients
* Connector for controller clients
*
* @extends module:lib/link.WebSocketBaseConnector
* @memberof module:lib/link
@@ -278,7 +278,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
}
/**
* Connect to the master server
* Connect to the controller
*/
async connect() {
this._check("closed");
@@ -294,7 +294,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
let url = new URL(this._url);
url.pathname += "api/socket";
// Open WebSocket to master
// Open WebSocket to controller
logger.verbose(`Connector | connecting to ${url}`);
// eslint-disable-next-line node/no-process-env
@@ -447,7 +447,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
let { type, data } = message;
if (type === "hello") {
logger.verbose(`Connector | received hello from master version ${data.version}`);
logger.verbose(`Connector | received hello from controller version ${data.version}`);
this.emit("hello", data);
if (this._sessionToken) {
logger.verbose("Connector | Attempting resume");
@@ -460,7 +460,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
}
} else if (type === "ready") {
logger.verbose("Connector | received ready from master");
logger.verbose("Connector | received ready from controller");
this._state = "connected";
this._sessionToken = data.session_token;
this._sessionTimeout = data.session_timeout;
@@ -485,7 +485,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
this.emit("resume");
} else if (type === "invalidate") {
logger.warn("Connector | session invalidated by master");
logger.warn("Connector | session invalidated by controller");
this._state = "connecting";
this._seq = 1;
this._lastReceivedSeq = null;
+3 -3
View File
@@ -6,10 +6,10 @@ const libErrors = require("../errors");
const { logger } = require("../logging");
// Some definitions for the terminology used here:
// link: Either side of a master - client connection
// link: Either side of a controller - client connection
// connector: Adapter between a link and a socket connection
// connection: the master server side of a link
// client: the side that is not the master server of a link
// connection: the controller side of a link
// client: the side that is not the controller of a link
// message: the complete object sent using the 'message' event
// data: the data property of a message, essentially the payload.
// type: the type property of a message, identifies what to expect in data.
+124 -122
View File
@@ -67,11 +67,11 @@ class Request extends Message {
* containing "<source>-<target>" specifications.
* @param {?string} permission -
* Permission required to send this request. Only applies to
* requests sent from control to master.
* requests sent from control to controller.
* @param {?string} forwardTo -
* Optional target to forward this request to. 'instance' add
* instance_id into the requestProperties and forward to the given
* instance. 'master' forwards it to the master server.
* instance. 'controller' forwards it to the controller.
* @param {?Array<string>} requestRequired -
* List of properties that are required to be present in the data
* payload of this request. Defaults to all.
@@ -101,11 +101,13 @@ class Request extends Message {
this.requestType = `${type}_request`;
this.responseType = `${type}_response`;
if (permission === undefined && links.includes("control-master")) {
throw new Error(`permission is required for ${this.type} request over control-master links`);
if (permission === undefined && links.includes("control-controller")) {
throw new Error(`permission is required for ${this.type} request over control-controller links`);
}
if (permission && !links.includes("control-master")) {
throw new Error(`permission is not allowed on ${this.type} request as it is not over control-master link`);
if (permission && !links.includes("control-controller")) {
throw new Error(
`permission is not allowed on ${this.type} request as it is not over control-controller link`
);
}
if (!requestRequired) {
@@ -119,7 +121,7 @@ class Request extends Message {
...requestProperties,
};
} else if (forwardTo !== "master" && forwardTo !== null) {
} else if (forwardTo !== "controller" && forwardTo !== null) {
throw new Error(`Invalid forwardTo value ${forwardTo}`);
}
@@ -176,7 +178,7 @@ class Request extends Message {
* If forwardTo was set to 'instance' the `forwardRequestToInstance`
* method on the link is used as the default handler.
*
* If forwardTo was set to 'master' the `forwardRequesToMaster` method
* If forwardTo was set to 'controller' the `forwardRequesToController` method
* on the link is used as the default handler.
*
* Does nothing if the link is neither a source nor a target for this
@@ -201,8 +203,8 @@ class Request extends Message {
if (!handler) {
if (this.forwardTo === "instance") {
handler = link.forwardRequestToInstance;
} else if (this.forwardTo === "master") {
handler = link.forwardRequestToMaster;
} else if (this.forwardTo === "controller") {
handler = link.forwardRequestToController;
}
}
@@ -210,8 +212,8 @@ class Request extends Message {
throw new MissingLinkHandlerError(this.requestType, link.source, link.target);
}
// Check permission if this is a handler for a control connection on the master
if (this.permission !== null && `${link.source}-${link.target}` === "master-control") {
// Check permission if this is a handler for a control connection on the controller
if (this.permission !== null && `${link.source}-${link.target}` === "controller-control") {
let origHandler = handler;
handler = async function(message, request) {
// Abuse this binding to get a hold of the ControlConnection instance
@@ -276,15 +278,15 @@ class Request extends Message {
let messages = {};
// Connection requests
let wsLinks = ["master-control", "control-master", "master-slave", "slave-master"];
let wsLinks = ["controller-control", "control-controller", "controller-slave", "slave-controller"];
messages.prepareDisconnect = new Request({
type: "prepare_disconnect",
links: wsLinks,
permission: null,
});
messages.prepareMasterDisconnect = new Request({
type: "prepare_master_disconnect",
messages.prepareControllerDisconnect = new Request({
type: "prepare_controller_disconnect",
links: ["slave-instance"],
});
@@ -296,35 +298,35 @@ messages.ping = new Request({
messages.debugDumpWs = new Request({
type: "debug_dump_ws",
links: ["control-master"],
links: ["control-controller"],
permission: "core.debug.dump_ws",
});
// Management requests
messages.getMasterConfig = new Request({
type: "get_master_config",
links: ["control-master"],
permission: "core.master.get_config",
messages.getControllerConfig = new Request({
type: "get_controller_config",
links: ["control-controller"],
permission: "core.controller.get_config",
responseProperties: {
"serialized_config": { type: "object" },
},
});
messages.setMasterConfigField = new Request({
type: "set_master_config_field",
links: ["control-master"],
permission: "core.master.update_config",
messages.setControllerConfigField = new Request({
type: "set_controller_config_field",
links: ["control-controller"],
permission: "core.controller.update_config",
requestProperties: {
"field": { type: "string" },
"value": { type: "string" },
},
});
messages.setMasterConfigProp = new Request({
type: "set_master_config_prop",
links: ["control-master"],
permission: "core.master.update_config",
messages.setControllerConfigProp = new Request({
type: "set_controller_config_prop",
links: ["control-controller"],
permission: "core.controller.update_config",
requestRequired: ["field", "prop"],
requestProperties: {
"field": { type: "string" },
@@ -344,7 +346,7 @@ let slaveProperties = {
messages.listSlaves = new Request({
type: "list_slaves",
links: ["control-master"],
links: ["control-controller"],
permission: "core.slave.list",
responseProperties: {
"list": {
@@ -360,7 +362,7 @@ messages.listSlaves = new Request({
messages.setSlaveSubscriptions = new Request({
type: "set_slave_subscriptions",
links: ["control-master"],
links: ["control-controller"],
permission: "core.slave.subscribe",
requestProperties: {
"all": { type: "boolean" },
@@ -384,7 +386,7 @@ let instanceProperties = {
messages.getInstance = new Request({
type: "get_instance",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.get",
requestProperties: {
"id": { type: "integer" },
@@ -394,7 +396,7 @@ messages.getInstance = new Request({
messages.listInstances = new Request({
type: "list_instances",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.list",
responseProperties: {
"list": {
@@ -410,7 +412,7 @@ messages.listInstances = new Request({
messages.setInstanceSubscriptions = new Request({
type: "set_instance_subscriptions",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.subscribe",
requestProperties: {
"all": { type: "boolean" },
@@ -423,7 +425,7 @@ messages.setInstanceSubscriptions = new Request({
messages.generateSlaveToken = new Request({
type: "generate_slave_token",
links: ["control-master"],
links: ["control-controller"],
permission: "core.slave.generate_token",
requestProperties: {
"slave_id": { type: ["integer", "null"] },
@@ -435,7 +437,7 @@ messages.generateSlaveToken = new Request({
messages.createSlaveConfig = new Request({
type: "create_slave_config",
links: ["control-master"],
links: ["control-controller"],
permission: "core.slave.create_config",
requestProperties: {
"id": { type: ["integer", "null"] },
@@ -449,7 +451,7 @@ messages.createSlaveConfig = new Request({
messages.createInstance = new Request({
type: "create_instance",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.create",
requestProperties: {
"serialized_config": { type: "object" },
@@ -458,7 +460,7 @@ messages.createInstance = new Request({
messages.getInstanceConfig = new Request({
type: "get_instance_config",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.get_config",
requestProperties: {
"instance_id": { type: "integer" },
@@ -470,7 +472,7 @@ messages.getInstanceConfig = new Request({
messages.setInstanceConfigField = new Request({
type: "set_instance_config_field",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.update_config",
requestProperties: {
"instance_id": { type: "integer" },
@@ -481,7 +483,7 @@ messages.setInstanceConfigField = new Request({
messages.setInstanceConfigProp = new Request({
type: "set_instance_config_prop",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.update_config",
requestRequired: ["instance_id", "field", "prop"],
requestProperties: {
@@ -494,7 +496,7 @@ messages.setInstanceConfigProp = new Request({
messages.assignInstanceCommand = new Request({
type: "assign_instance_command",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.assign",
requestProperties: {
"instance_id": { type: "integer" },
@@ -504,7 +506,7 @@ messages.assignInstanceCommand = new Request({
messages.startInstance = new Request({
type: "start_instance",
links: ["control-master", "master-slave", "slave-instance"],
links: ["control-controller", "controller-slave", "slave-instance"],
permission: "core.instance.start",
requestProperties: {
"save": { type: ["string", "null"] },
@@ -531,7 +533,7 @@ let saveList = {
messages.listSaves = new Request({
type: "list_saves",
links: ["control-master", "master-slave", "slave-instance"],
links: ["control-controller", "controller-slave", "slave-instance"],
permission: "core.instance.save.list",
forwardTo: "instance",
responseProperties: {
@@ -541,7 +543,7 @@ messages.listSaves = new Request({
messages.createSave = new Request({
type: "create_save",
links: ["control-master", "master-slave", "slave-instance"],
links: ["control-controller", "controller-slave", "slave-instance"],
permission: "core.instance.save.create",
forwardTo: "instance",
requestProperties: {
@@ -554,7 +556,7 @@ messages.createSave = new Request({
messages.renameSave = new Request({
type: "rename_save",
links: ["control-master", "master-slave"],
links: ["control-controller", "controller-slave"],
permission: "core.instance.save.rename",
forwardTo: "instance",
requestProperties: {
@@ -565,7 +567,7 @@ messages.renameSave = new Request({
messages.copySave = new Request({
type: "copy_save",
links: ["control-master", "master-slave"],
links: ["control-controller", "controller-slave"],
permission: "core.instance.save.copy",
forwardTo: "instance",
requestProperties: {
@@ -576,7 +578,7 @@ messages.copySave = new Request({
messages.deleteSave = new Request({
type: "delete_save",
links: ["control-master", "master-slave"],
links: ["control-controller", "controller-slave"],
permission: "core.instance.save.delete",
forwardTo: "instance",
requestProperties: {
@@ -586,7 +588,7 @@ messages.deleteSave = new Request({
messages.downloadSave = new Request({
type: "download_save",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.save.download",
requestProperties: {
"instance_id": { type: "integer" },
@@ -599,7 +601,7 @@ messages.downloadSave = new Request({
messages.transferSave = new Request({
type: "transfer_save",
links: ["control-master", "master-slave"],
links: ["control-controller", "controller-slave"],
permission: "core.instance.save.transfer",
requestProperties: {
"instance_id": { type: "integer" },
@@ -615,7 +617,7 @@ messages.transferSave = new Request({
messages.pullSave = new Request({
type: "pull_save",
links: ["master-slave"],
links: ["controller-slave"],
requestProperties: {
"instance_id": { type: "integer" },
"stream_id": { type: "string" },
@@ -628,7 +630,7 @@ messages.pullSave = new Request({
messages.pushSave = new Request({
type: "push_save",
links: ["master-slave"],
links: ["controller-slave"],
requestProperties: {
"instance_id": { type: "integer" },
"stream_id": { type: "string" },
@@ -638,7 +640,7 @@ messages.pushSave = new Request({
messages.setSaveListSubscriptions = new Request({
type: "set_save_list_subscriptions",
links: ["control-master"],
links: ["control-controller"],
permission: "core.instance.save.list_subscribe",
requestProperties: {
"all": { type: "boolean" },
@@ -651,7 +653,7 @@ messages.setSaveListSubscriptions = new Request({
messages.loadScenario = new Request({
type: "load_scenario",
links: ["control-master", "master-slave", "slave-instance"],
links: ["control-controller", "controller-slave", "slave-instance"],
permission: "core.instance.load_scenario",
forwardTo: "instance",
requestProperties: {
@@ -664,42 +666,42 @@ messages.loadScenario = new Request({
messages.exportData = new Request({
type: "export_data",
links: ["control-master", "master-slave", "slave-instance"],
links: ["control-controller", "controller-slave", "slave-instance"],
permission: "core.instance.export_data",
forwardTo: "instance",
});
messages.extractPlayers = new Request({
type: "extract_players",
links: ["control-master", "master-slave", "slave-instance"],
links: ["control-controller", "controller-slave", "slave-instance"],
permission: "core.instance.extract_players",
forwardTo: "instance",
});
messages.stopInstance = new Request({
type: "stop_instance",
links: ["control-master", "master-slave", "slave-instance"],
links: ["control-controller", "controller-slave", "slave-instance"],
permission: "core.instance.stop",
forwardTo: "instance",
});
messages.killInstance = new Request({
type: "kill_instance",
links: ["control-master", "master-slave", "slave-instance"],
links: ["control-controller", "controller-slave", "slave-instance"],
permission: "core.instance.kill",
forwardTo: "instance",
});
messages.deleteInstance = new Request({
type: "delete_instance",
links: ["control-master", "master-slave"],
links: ["control-controller", "controller-slave"],
permission: "core.instance.delete",
forwardTo: "instance",
});
messages.sendRcon = new Request({
type: "send_rcon",
links: ["control-master", "master-slave", "slave-instance"],
links: ["control-controller", "controller-slave", "slave-instance"],
permission: "core.instance.send_rcon",
forwardTo: "instance",
requestProperties: {
@@ -712,9 +714,9 @@ messages.sendRcon = new Request({
messages.getModPack = new Request({
type: "get_mod_pack",
links: ["control-master", "instance-slave", "slave-master"],
links: ["control-controller", "instance-slave", "slave-controller"],
permission: "core.mod_pack.get",
forwardTo: "master",
forwardTo: "controller",
requestProperties: {
"id": { type: "integer" },
},
@@ -725,9 +727,9 @@ messages.getModPack = new Request({
messages.getDefaultModPack = new Request({
type: "get_default_mod_pack",
links: ["control-master", "instance-slave", "slave-master"],
links: ["control-controller", "instance-slave", "slave-controller"],
permission: "core.mod_pack.get",
forwardTo: "master",
forwardTo: "controller",
responseProperties: {
"mod_pack": libData.ModPack.jsonSchema,
},
@@ -735,7 +737,7 @@ messages.getDefaultModPack = new Request({
messages.listModPacks = new Request({
type: "list_mod_packs",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod_pack.list",
responseProperties: {
"list": {
@@ -747,7 +749,7 @@ messages.listModPacks = new Request({
messages.createModPack = new Request({
type: "create_mod_pack",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod_pack.create",
requestProperties: {
"mod_pack": libData.ModPack.jsonSchema,
@@ -756,7 +758,7 @@ messages.createModPack = new Request({
messages.updateModPack = new Request({
type: "update_mod_pack",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod_pack.update",
requestProperties: {
"mod_pack": libData.ModPack.jsonSchema,
@@ -765,7 +767,7 @@ messages.updateModPack = new Request({
messages.deleteModPack = new Request({
type: "delete_mod_pack",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod_pack.delete",
requestProperties: {
"id": { type: "integer" },
@@ -774,7 +776,7 @@ messages.deleteModPack = new Request({
messages.setModPackSubscriptions = new Request({
type: "set_mod_pack_subscriptions",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod_pack.subscribe",
requestProperties: {
"all": { type: "boolean" },
@@ -787,7 +789,7 @@ messages.setModPackSubscriptions = new Request({
messages.getMod = new Request({
type: "get_mod",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod.get",
requestProperties: {
"name": { type: "string" },
@@ -800,7 +802,7 @@ messages.getMod = new Request({
messages.listMods = new Request({
type: "list_mods",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod.list",
responseProperties: {
"list": {
@@ -812,7 +814,7 @@ messages.listMods = new Request({
messages.searchMods = new Request({
type: "search_mods",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod.search",
requestRequired: ["query", "factorio_version", "page"],
requestProperties: {
@@ -848,7 +850,7 @@ messages.searchMods = new Request({
messages.setModSubscriptions = new Request({
type: "set_mod_subscriptions",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod.subscribe",
requestProperties: {
"all": { type: "boolean" },
@@ -861,7 +863,7 @@ messages.setModSubscriptions = new Request({
messages.downloadMod = new Request({
type: "download_mod",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod.download",
requestProperties: {
"name": { type: "string" },
@@ -874,7 +876,7 @@ messages.downloadMod = new Request({
messages.deleteMod = new Request({
type: "delete_mod",
links: ["control-master"],
links: ["control-controller"],
permission: "core.mod.delete",
requestProperties: {
"name": { type: "string" },
@@ -884,7 +886,7 @@ messages.deleteMod = new Request({
messages.listPermissions = new Request({
type: "list_permissions",
links: ["control-master"],
links: ["control-controller"],
permission: "core.permission.list",
responseProperties: {
"list": {
@@ -904,7 +906,7 @@ messages.listPermissions = new Request({
messages.listRoles = new Request({
type: "list_roles",
links: ["control-master"],
links: ["control-controller"],
permission: "core.role.list",
responseProperties: {
"list": {
@@ -925,7 +927,7 @@ messages.listRoles = new Request({
messages.createRole = new Request({
type: "create_role",
links: ["control-master"],
links: ["control-controller"],
permission: "core.role.create",
requestProperties: {
"name": { type: "string" },
@@ -939,7 +941,7 @@ messages.createRole = new Request({
messages.updateRole = new Request({
type: "update_role",
links: ["control-master"],
links: ["control-controller"],
permission: "core.role.update",
requestProperties: {
"id": { type: "integer" },
@@ -951,7 +953,7 @@ messages.updateRole = new Request({
messages.grantDefaultRolePermissions = new Request({
type: "grant_default_role_permissions",
links: ["control-master"],
links: ["control-controller"],
permission: "core.role.update",
requestProperties: {
"id": { type: "integer" },
@@ -960,7 +962,7 @@ messages.grantDefaultRolePermissions = new Request({
messages.deleteRole = new Request({
type: "delete_role",
links: ["control-master"],
links: ["control-controller"],
permission: "core.role.delete",
requestProperties: {
"id": { type: "integer" },
@@ -989,7 +991,7 @@ const userProperties = {
messages.getUser = new Request({
type: "get_user",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.get",
requestProperties: {
"name": { type: "string" },
@@ -1000,7 +1002,7 @@ messages.getUser = new Request({
messages.listUsers = new Request({
type: "list_users",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.list",
responseProperties: {
"list": {
@@ -1016,7 +1018,7 @@ messages.listUsers = new Request({
messages.setUserSubscriptions = new Request({
type: "set_user_subscriptions",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.subscribe",
requestProperties: {
"all": { type: "boolean" },
@@ -1029,7 +1031,7 @@ messages.setUserSubscriptions = new Request({
messages.createUser = new Request({
type: "create_user",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.create",
requestProperties: {
"name": { type: "string" },
@@ -1038,7 +1040,7 @@ messages.createUser = new Request({
messages.revokeUserToken = new Request({
type: "revoke_user_token",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.revoke_token",
requestProperties: {
"name": { type: "string" },
@@ -1047,7 +1049,7 @@ messages.revokeUserToken = new Request({
messages.updateUserRoles = new Request({
type: "update_user_roles",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.update_roles",
requestProperties: {
"name": { type: "string" },
@@ -1057,7 +1059,7 @@ messages.updateUserRoles = new Request({
messages.setUserAdmin = new Request({
type: "set_user_admin",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.set_admin",
requestProperties: {
"name": { type: "string" },
@@ -1068,7 +1070,7 @@ messages.setUserAdmin = new Request({
messages.setUserWhitelisted = new Request({
type: "set_user_whitelisted",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.set_whitelisted",
requestProperties: {
"name": { type: "string" },
@@ -1079,7 +1081,7 @@ messages.setUserWhitelisted = new Request({
messages.setUserBanned = new Request({
type: "set_user_banned",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.set_banned",
requestProperties: {
"name": { type: "string" },
@@ -1091,7 +1093,7 @@ messages.setUserBanned = new Request({
messages.deleteUser = new Request({
type: "delete_user",
links: ["control-master"],
links: ["control-controller"],
permission: "core.user.delete",
requestProperties: {
"name": { type: "string" },
@@ -1100,11 +1102,11 @@ messages.deleteUser = new Request({
messages.setLogSubscriptions = new Request({
type: "set_log_subscriptions",
links: ["control-master"],
links: ["control-controller"],
permission: "core.log.follow",
requestProperties: {
"all": { type: "boolean" },
"master": { type: "boolean" },
"controller": { type: "boolean" },
"slave_ids": {
type: "array",
items: { type: "integer" },
@@ -1119,11 +1121,11 @@ messages.setLogSubscriptions = new Request({
messages.queryLog = new Request({
type: "query_log",
links: ["control-master"],
links: ["control-controller"],
permission: "core.log.query",
requestProperties: {
"all": { type: "boolean" },
"master": { type: "boolean" },
"controller": { type: "boolean" },
"slave_ids": {
type: "array",
items: { type: "integer" },
@@ -1148,7 +1150,7 @@ messages.queryLog = new Request({
// Internal requests
messages.updateInstances = new Request({
type: "update_instances",
links: ["slave-master"],
links: ["slave-controller"],
requestProperties: {
"instances": {
type: "array",
@@ -1169,7 +1171,7 @@ messages.updateInstances = new Request({
messages.assignInstance = new Request({
type: "assign_instance",
links: ["master-slave"],
links: ["controller-slave"],
requestProperties: {
"serialized_config": { type: "object" },
},
@@ -1178,13 +1180,13 @@ messages.assignInstance = new Request({
messages.unassignInstance = new Request({
type: "unassigne_instance",
links: ["master-slave"],
links: ["controller-slave"],
forwardTo: "instance",
});
messages.getMetrics = new Request({
type: "get_metrics",
links: ["master-slave", "slave-instance"],
links: ["controller-slave", "slave-instance"],
responseProperties: {
"results": { type: "array" },
},
@@ -1213,7 +1215,7 @@ class Event extends Message {
* containing "<source>-<target>" specifications.
* @param {?string} forwardTo -
* Optional target to forward this request to. Supported values are
* 'master' and 'instance'. If set to 'instance' an instance_id
* 'controller' and 'instance'. If set to 'instance' an instance_id
* property is implicity added to eventProperties.
* @param {?string} broadcastTo -
* Optional target to broadcast this event to. Only 'instance' is
@@ -1247,7 +1249,7 @@ class Event extends Message {
...eventProperties,
};
} else if (forwardTo !== "master" && forwardTo !== null) {
} else if (forwardTo !== "controller" && forwardTo !== null) {
throw new Error(`Invalid forwardTo value ${forwardTo}`);
}
@@ -1275,7 +1277,7 @@ class Event extends Message {
* Set a the handler for the event on the given link if it's a target
* for the event.
*
* If forwardTo was set to 'master' the `forwardEventToMaster` method on
* If forwardTo was set to 'controller' the `forwardEventToController` method on
* the link is used as the default handler. If it was set to 'instance'
* the `forwardEventToInstance` method on the link is used by default.
*
@@ -1297,15 +1299,15 @@ class Event extends Message {
if (!handler) {
if (this.forwardTo === "instance") {
handler = link.forwardEventToInstance;
} else if (this.forwardTo === "master") {
handler = link.forwardEventToMaster;
} else if (this.forwardTo === "controller") {
handler = link.forwardEventToController;
}
}
if (
this.broadcastTo === "instance"
&& [
"instance-slave", "slave-master", "control-master", "master-slave",
"instance-slave", "slave-controller", "control-controller", "controller-slave",
].includes(`${link.target}-${link.source}`)
) {
if (!handler) {
@@ -1352,7 +1354,7 @@ class Event extends Message {
messages.debugWsMessage = new Event({
type: "debug_ws_message",
links: ["master-control"],
links: ["controller-control"],
eventProperties: {
"direction": { type: "string" },
"content": { type: "string" },
@@ -1361,7 +1363,7 @@ messages.debugWsMessage = new Event({
messages.accountUpdate = new Event({
type: "account_update",
links: ["master-control"],
links: ["controller-control"],
eventRequired: [],
eventProperties: {
"roles": {
@@ -1385,7 +1387,7 @@ messages.accountUpdate = new Event({
messages.logMessage = new Event({
type: "log_message",
links: ["slave-master", "master-control"],
links: ["slave-controller", "controller-control"],
eventProperties: {
"info": {
type: "object",
@@ -1400,7 +1402,7 @@ messages.logMessage = new Event({
messages.slaveUpdate = new Event({
type: "slave_update",
links: ["master-control"],
links: ["controller-control"],
eventProperties: slaveProperties,
});
@@ -1418,7 +1420,7 @@ messages.instanceInitialized = new Event({
});
messages.instanceStatusChanged = new Event({
type: "instance_status_changed",
links: ["instance-slave", "slave-master"],
links: ["instance-slave", "slave-controller"],
eventRequired: ["instance_id", "status"],
eventProperties: {
"instance_id": { type: "integer" },
@@ -1431,14 +1433,14 @@ messages.instanceStatusChanged = new Event({
messages.instanceUpdate = new Event({
type: "instance_update",
links: ["master-control"],
links: ["controller-control"],
eventProperties: instanceProperties,
});
messages.saveListUpdate = new Event({
type: "save_list_update",
links: ["instance-slave", "slave-master", "master-control"],
forwardTo: "master",
links: ["instance-slave", "slave-controller", "controller-control"],
forwardTo: "controller",
eventProperties: {
"instance_id": { type: "integer" },
"list": saveList,
@@ -1447,7 +1449,7 @@ messages.saveListUpdate = new Event({
messages.modPackUpdate = new Event({
type: "mod_pack_update",
links: ["master-control"],
links: ["controller-control"],
eventProperties: {
"mod_pack": libData.ModPack.jsonSchema,
},
@@ -1455,7 +1457,7 @@ messages.modPackUpdate = new Event({
messages.modUpdate = new Event({
type: "mod_update",
links: ["master-control"],
links: ["controller-control"],
eventProperties: {
"mod": libData.ModInfo.jsonSchema,
},
@@ -1463,13 +1465,13 @@ messages.modUpdate = new Event({
messages.userUpdate = new Event({
type: "user_update",
links: ["master-control"],
links: ["controller-control"],
eventRequired: userRequired,
eventProperties: userProperties,
});
messages.masterConnectionEvent = new Event({
type: "master_connection_event",
messages.controllerConnectionEvent = new Event({
type: "controller_connection_event",
links: ["slave-instance"],
eventProperties: {
"event": { type: "string" },
@@ -1478,7 +1480,7 @@ messages.masterConnectionEvent = new Event({
messages.syncUserLists = new Event({
type: "sync_user_lists",
links: ["master-slave"],
links: ["controller-slave"],
eventProperties: {
"adminlist": {
type: "array",
@@ -1501,7 +1503,7 @@ messages.syncUserLists = new Event({
messages.banlistUpdate = new Event({
type: "banlist_update",
links: ["master-slave", "slave-instance"],
links: ["controller-slave", "slave-instance"],
broadcastTo: "instance",
eventProperties: {
"name": { type: "string" },
@@ -1512,7 +1514,7 @@ messages.banlistUpdate = new Event({
messages.adminlistUpdate = new Event({
type: "adminlist_update",
links: ["master-slave", "slave-instance"],
links: ["controller-slave", "slave-instance"],
eventProperties: {
"name": { type: "string" },
"admin": { type: "boolean" },
@@ -1522,7 +1524,7 @@ messages.adminlistUpdate = new Event({
messages.whitelistUpdate = new Event({
type: "whitelist_update",
links: ["master-slave", "slave-instance"],
links: ["controller-slave", "slave-instance"],
eventProperties: {
"name": { type: "string" },
"whitelisted": { type: "boolean" },
@@ -1532,8 +1534,8 @@ messages.whitelistUpdate = new Event({
messages.playerEvent = new Event({
type: "player_event",
links: ["instance-slave", "slave-master"],
forwardTo: "master",
links: ["instance-slave", "slave-controller"],
forwardTo: "controller",
eventRequired: ["instance_id", "type", "name"],
eventProperties: {
"instance_id": { type: "integer" },
+5 -5
View File
@@ -88,9 +88,9 @@ class WebConsoleFormat {
* @property {string} [max_level] -
* Maximum log level to include. Higher levels are more verbose.
* @property {boolean} [all] -
* Include log entries from master, all slaves and all instances.
* @property {boolean} [master] -
* Include log entries from the master server.
* Include log entries from controller, all slaves and all instances.
* @property {boolean} [controller] -
* Include log entries from the controller.
* @property {Array<number>} [slave_ids] -
* Include log entries for the given slaves and instances of those
* slaves by id.
@@ -107,7 +107,7 @@ class WebConsoleFormat {
* filter returning true for log entries that match it.
* @static
*/
function logFilter({ all, master, slave_ids, instance_ids, max_level }) {
function logFilter({ all, controller, slave_ids, instance_ids, max_level }) {
return info => {
// Note: reversed to filter out undefined levels
if (max_level && !(levels[info.level] <= levels[max_level])) {
@@ -117,7 +117,7 @@ function logFilter({ all, master, slave_ids, instance_ids, max_level }) {
if (all) {
return true;
}
if (master && info.slave_id === undefined) {
if (controller && info.slave_id === undefined) {
return true;
}
if (
+10 -10
View File
@@ -157,7 +157,7 @@ class LogIndex {
for (let [file, serializedEntry] of Object.entries(serialized.files)) {
this.index.set(file, {
levels: new Set(serializedEntry.levels),
master: serializedEntry.master,
controller: serializedEntry.controller,
slave_ids: new Set(serializedEntry.slave_ids),
instance_ids: new Set(serializedEntry.instance_ids),
});
@@ -173,7 +173,7 @@ class LogIndex {
for (let [file, entry] of this.index) {
serialized.files[file] = {
levels: [...entry.levels],
master: entry.master,
controller: entry.controller,
slave_ids: [...entry.slave_ids],
instance_ids: [...entry.instance_ids],
};
@@ -224,7 +224,7 @@ class LogIndex {
fileStream.pipe(lineStream);
let entry = {
levels: new Set(),
master: false,
controller: false,
slave_ids: new Set(),
instance_ids: new Set(),
};
@@ -234,14 +234,14 @@ class LogIndex {
info = JSON.parse(line);
} catch (err) {
entry.levels.add("info");
entry.master = true;
entry.controller = true;
continue;
}
if (info.level) {
entry.levels.add(info.level);
}
if (info.slave_id === undefined) {
entry.master = true;
entry.controller = true;
} else if (info.instance_id === undefined) {
entry.slave_ids.add(info.slave_id);
}
@@ -279,7 +279,7 @@ class LogIndex {
* @returns {boolean}
* true if the file may contain entries included by the filter.
*/
filterIncludesFile(file, { max_level, all, master, instance_ids, slave_ids }) {
filterIncludesFile(file, { max_level, all, controller, instance_ids, slave_ids }) {
let entry = this.index.get(file);
if (!entry) {
return true;
@@ -298,7 +298,7 @@ class LogIndex {
if (all) {
return true;
}
if (master && entry.master) {
if (controller && entry.controller) {
return true;
}
if (slave_ids && slave_ids.some(id => entry.slave_ids.has(id))) {
@@ -321,9 +321,9 @@ class LogIndex {
* @property {string} [max_level] -
* Maximum log level to include. Higher levels are more verbose.
* @property {boolean} [all] -
* Include log entries from master, all slaves and all instances.
* @property {boolean} [master] -
* Include log entries from the master server.
* Include log entries from controller, all slaves and all instances.
* @property {boolean} [controller] -
* Include log entries from the controller.
* @property {Array<number>} [slave_ids] -
* Include log entries for the given slaves and instances of those
* slaves by id.
+62 -62
View File
@@ -7,9 +7,9 @@
const helpers = require("./helpers");
/**
* Conceptual base for master and instance plugins.
* Conceptual base for controller and instance plugins.
* @typedef {
* module:lib/plugin.BaseMasterPlugin
* module:lib/plugin.BaseControllerPlugin
* |module:lib/plugin.BaseInstancePlugin
* |module:lib/plugin.BaseControlPlugin
* } module:lib/plugin.BasePlugin
@@ -150,22 +150,22 @@ class BaseInstancePlugin {
async onOutput(parsed, line) { }
/**
* Called when an event on the master connection happens
* Called when an event on the controller connection happens
*
* The event param may be one of connect, drop, resume and close and has
* the following meaning:
*
* ##### connect
*
* Invoked when a new connection to the master has been established.
* Invoked when a new connection to the controller has been established.
*
* ##### drop
*
* Invoked when a connection loss is detected between the slave and the
* master. Plugins should respond to this event by throtteling messages
* it is sending to the master to an absolute minimum.
* controller. Plugins should respond to this event by throtteling messages
* it is sending to the controller to an absolute minimum.
*
* Messages sent over a dropped master connection will get queued up in
* Messages sent over a dropped controller connection will get queued up in
* memory on the slave and sent all in one go when the connection is
* re-established again.
*
@@ -176,29 +176,29 @@ class BaseInstancePlugin {
*
* ##### close
*
* Invoked when the connection to the master has been closed. This
* typically means the master server has shut down. Plugins should not
* send any messages that goes to or via the master server after the
* Invoked when the connection to the controller has been closed. This
* typically means the controller has shut down. Plugins should not
* send any messages that goes to or via the controller after the
* connection has been closed and before a new one is established.
*
* @param {string} event - one of connect, drop, resume and close
*/
onMasterConnectionEvent(event) { }
onControllerConnectionEvent(event) { }
/**
* Called when the master is preparing to disconnect from the slave
* Called when the controller is preparing to disconnect from the slave
*
* Invoked when the master server has requested the disconnection from
* Invoked when the controller has requested the disconnection from
* the slave. This typically happens when it is in the process of
* shutting down.
*
* Plugins must stop sending messages to the master, or are forwarded
* via the master server after the prepare disconnect has been handled.
* Plugins must stop sending messages to the controller, or are forwarded
* via the controller after the prepare disconnect has been handled.
*
* @param {module:master/src/SlaveConnection} connection -
* @param {module:controller/src/SlaveConnection} connection -
* The connection to the slave preparing to disconnect.
*/
async onPrepareMasterDisconnect(connection) { }
async onPrepareControllerDisconnect(connection) { }
/**
* Called when a player joins or leaves the game
@@ -284,25 +284,25 @@ class BaseInstancePlugin {
}
/**
* Base class for master plugins
* Base class for controller plugins
*
* Master plugins are subclasses of this class which get instantiated by
* the master server on startup when the plugin is enabled in the config.
* To be discovered the class must be exported under the name `MasterPlugin`
* in the module specified by the `masterEntrypoint` in the plugin's info.js
* Controller plugins are subclasses of this class which get instantiated by
* the controller on startup when the plugin is enabled in the config.
* To be discovered the class must be exported under the name `ControllerPlugin`
* in the module specified by the `controllerEntrypoint` in the plugin's info.js
* file.
*
* @static
*/
class BaseMasterPlugin {
constructor(info, master, metrics, logger) {
class BaseControllerPlugin {
constructor(info, controller, metrics, logger) {
this.info = info;
/**
* Master server
* @type {module:master/src/Master}
* Controller
* @type {module:controller/src/Controller}
*/
this.master = master;
this.controller = controller;
this.metrics = metrics;
/**
@@ -323,7 +323,7 @@ class BaseMasterPlugin {
/**
* Called when the status of an instance changes
*
* Invoked when the master server has changed the status of an instance
* Invoked when the controller has changed the status of an instance
* or received notice from a slave that the status of an instance has
* changed. The possible statuses that can be notified about are:
* - `unassigned:`: Instance is no longer asssigned to a slave.
@@ -338,21 +338,21 @@ class BaseMasterPlugin {
* icons and locale data.
* - `deleted`: Instance was deleted.
*
* On master startup all known instances gets the status `unknown` if
* On controller startup all known instances gets the status `unknown` if
* they are assigned to a slave, when the slave then connects to the
* master and informs of the current status of its instances this hook
* controller and informs of the current status of its instances this hook
* is invoked for all those instances. You can detect this situation by
* checking if prev equals `unknown`. If the slave disconnects the
* instances will again get the `unknown` status.
*
* When instances are created on the master they will notify of a status
* When instances are created on the controller they will notify of a status
* change with prev set to null. While the status of new instances is
* in most cases `unassigned` it's possible for the created instance to
* start with any state in some slave connection corner cases.
*
* Note that it's possible for status change notification to get lost in
* the case of network outages if reconnect fails to re-establish the
* session between the master server and the slave.
* session between the controller and the slave.
*
* @param {Object} instance - the instance that changed.
* @param {?string} prev - the previous status of the instance.
@@ -360,17 +360,17 @@ class BaseMasterPlugin {
async onInstanceStatusChanged(instance, prev) { }
/**
* Called when the value of a master config field changed.
* Called when the value of a controller config field changed.
*
* Invoked after the value of the config field given by `field` has
* changed on the master.
* changed on the controller.
*
* @param {module:lib/config.ConfigGroup} group -
* The group who's field got changed.
* @param {string} field - Name of the field that changed.
* @param {*} prev - The previous value of the field.
*/
async onMasterConfigFieldChanged(group, field, prev) { }
async onControllerConfigFieldChanged(group, field, prev) { }
/**
* Called when the value of an instance config field changed.
@@ -404,7 +404,7 @@ class BaseMasterPlugin {
async onMetrics() { }
/**
* Called when the master server is shutting down
* Called when the controller is shutting down
*/
async onShutdown() { }
@@ -420,12 +420,12 @@ class BaseMasterPlugin {
*
* ##### drop
*
* Invoked when a connection loss is detected between the master and a
* Invoked when a connection loss is detected between the controller and a
* slave. Plugins should respond to this event by throtteling messages
* it is sending to the given slave connection to an absolute minimum.
*
* Messages sent over a dropped slave connection will get queued up in
* memory on the master and sent all in one go when the connection is
* memory on the controller and sent all in one go when the connection is
* re-established again.
*
* ##### resume
@@ -437,7 +437,7 @@ class BaseMasterPlugin {
*
* Invoked when the connection to the slave has been closed.
*
* @param {module:master/src/SlaveConnection} connection -
* @param {module:controller/src/SlaveConnection} connection -
* The connection the event occured on.
* @param {string} event - one of connect, drop, resume and close
*/
@@ -455,13 +455,13 @@ class BaseMasterPlugin {
*
* ##### drop
*
* Invoked when a connection loss is detected between the master and a
* Invoked when a connection loss is detected between the controller and a
* control. Plugins should respond to this event by throtteling
* messages it is sending to the given control connection to an absolute
* minimum.
*
* Messages sent over a dropped control connection will get queued up in
* memory on the master and sent all in one go when the connection is
* memory on the controller and sent all in one go when the connection is
* re-established again.
*
* ##### resume
@@ -473,22 +473,22 @@ class BaseMasterPlugin {
*
* Invoked when the connection to the control has been closed.
*
* @param {module:master/src/ControlConnection} connection -
* @param {module:controller/src/ControlConnection} connection -
* The connection the event occured on.
* @param {string} event - one of connect, drop, resume, and close.
*/
onControlConnectionEvent(connection, event) { }
/**
* Called when a slave is preparing to disconnect from the master
* Called when a slave is preparing to disconnect from the controller
*
* Invoked when a slave has requested the disconnection from the master.
* Invoked when a slave has requested the disconnection from the controller.
* This typically happens when it is in the process of shutting down.
*
* Plugins must stop sending messages to the slave in question after the
* prepare disconnect has been handled.
*
* @param {module:master/src/SlaveConnection} connection -
* @param {module:controller/src/SlaveConnection} connection -
* The connection to the slave preparing to disconnect.
*/
async onPrepareSlaveDisconnect(connection) { }
@@ -507,7 +507,7 @@ class BaseMasterPlugin {
async onModPackUpdated(modPack) { }
/**
* Called when a mod stored on the master server is updated
* Called when a mod stored on the controller is updated
*
* Invoked when a mod has been added, updated or deleted from the pool
* of shared mods stored on the cluster.
@@ -538,7 +538,7 @@ class BaseMasterPlugin {
/**
* Broadcast event to all connected slaves
*
* Sends the given event to all slaves connected to the master server.
* Sends the given event to all slaves connected to the controller.
* This does not include slaves that are in the process of closing the
* connection, which typically happens when they are shutting down.
*
@@ -546,7 +546,7 @@ class BaseMasterPlugin {
* @param {Object} data - Data ta pass with the event.
*/
broadcastEventToSlaves(event, data={}) {
for (let slaveConnection of this.master.wsServer.slaveConnections.values()) {
for (let slaveConnection of this.controller.wsServer.slaveConnections.values()) {
if (
!slaveConnection.connector.closing
&& (!event.plugin || slaveConnection.plugins.has(event.plugin))
@@ -660,8 +660,8 @@ class BaseWebPlugin {
this.info = info;
/**
* Control link to the master server, not available until the
* connect event in onMasterConnectionEvent is signaled.
* Control link to the controller, not available until the
* connect event in onControllerConnectionEvent is signaled.
* @type {?module:lib/link.Link}
*/
this.control = null;
@@ -700,8 +700,8 @@ class BaseWebPlugin {
* component extra.
*
* @type {object}
* @property {React.ComponentType} MasterPage -
* Placed at the end of the master page.
* @property {React.ComponentType} ControllerPage -
* Placed at the end of the controller page.
* @property {React.ComponentType} SlavesPage -
* Placed at the end of the slaves list page.
* @property {React.ComponentType} SlaveViewPage -
@@ -732,22 +732,22 @@ class BaseWebPlugin {
async init() { }
/**
* Called when an event on the master connection happens
* Called when an event on the controller connection happens
*
* The event param may be one of connect, drop, resume and close and has
* the following meaning:
*
* ##### connect
*
* Invoked when a new connection to the master has been established.
* Invoked when a new connection to the controller has been established.
*
* ##### drop
*
* Invoked when a connection loss is detected between the control link
* and the master. Plugins should respond to this event by throtteling
* messages it is sending to the master to an absolute minimum.
* and the controller. Plugins should respond to this event by throtteling
* messages it is sending to the controller to an absolute minimum.
*
* Messages sent over a dropped master connection will get queued up in
* Messages sent over a dropped controller connection will get queued up in
* memory in the browser and sent all in one go when the connection is
* re-established again.
*
@@ -758,14 +758,14 @@ class BaseWebPlugin {
*
* ##### close
*
* Invoked when the connection to the master has been closed. This
* typically means the master server has shut down. Plugins should not
* send any messages that goes to or via the master server after the
* Invoked when the connection to the controller has been closed. This
* typically means the controller has shut down. Plugins should not
* send any messages that goes to or via the controller after the
* connection has been closed and before a new one is established.
*
* @param {string} event - one of connect, drop, resume and close
*/
onMasterConnectionEvent(event) { }
onControllerConnectionEvent(event) { }
}
/**
@@ -840,7 +840,7 @@ async function invokeHook(plugins, hook, ...args) {
module.exports = {
BaseInstancePlugin,
BaseMasterPlugin,
BaseControllerPlugin,
BaseControlPlugin,
BaseWebPlugin,
+4 -4
View File
@@ -66,7 +66,7 @@ function loadPluginClass(entrypointName, className, pluginClass, pluginInfo) {
}
/**
* Load master plugin class of a plugin
* Load controller plugin class of a plugin
*
* @param {Object} pluginInfo -
* Plugin info object returned from {@link
@@ -74,8 +74,8 @@ function loadPluginClass(entrypointName, className, pluginClass, pluginInfo) {
* @returns {Promise<function>} plugin class
* @static
*/
async function loadMasterPluginClass(pluginInfo) {
return loadPluginClass("masterEntrypoint", "MasterPlugin", libPlugin.BaseMasterPlugin, pluginInfo);
async function loadControllerPluginClass(pluginInfo) {
return loadPluginClass("controllerEntrypoint", "ControllerPlugin", libPlugin.BaseControllerPlugin, pluginInfo);
}
/**
@@ -106,7 +106,7 @@ async function loadControlPluginClass(pluginInfo) {
module.exports = {
loadPluginInfos,
loadMasterPluginClass,
loadControllerPluginClass,
loadInstancePluginClass,
loadControlPluginClass,
};
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Implementation of commands shared between master/slave/ctl.
* Implementation of commands shared between controller/slave/ctl.
* @module lib/shared_commands
*/
"use strict";
+16 -16
View File
@@ -350,19 +350,19 @@ definePermission({
definePermission({
name: "core.control.connect",
title: "Connect to WebSocket",
description: "Connect to the master's WebSocket control interface.",
description: "Connect to the controller's WebSocket control interface.",
grantByDefault: true,
});
definePermission({
name: "core.master.get_config",
title: "Get master config",
description: "Get the config of master.",
name: "core.controller.get_config",
title: "Get controller config",
description: "Get the config of controller.",
});
definePermission({
name: "core.master.update_config",
title: "Modify master config",
description: "Modify the master config or entries of the master config.",
name: "core.controller.update_config",
title: "Modify controller config",
description: "Modify the controller config or entries of the controller config.",
});
definePermission({
name: "core.slave.list",
@@ -384,7 +384,7 @@ definePermission({
definePermission({
name: "core.slave.create_config",
title: "Create slave config",
description: "Create slave configs via the master server.",
description: "Create slave configs via the controller.",
});
definePermission({
@@ -408,7 +408,7 @@ definePermission({
definePermission({
name: "core.instance.create",
title: "Create instance",
description: "Create new instances on the master server.",
description: "Create new instances on the controller.",
});
definePermission({
name: "core.instance.get_config",
@@ -473,7 +473,7 @@ definePermission({
definePermission({
name: "core.instance.export_data",
title: "Export locale and icons",
description: "Export the the locale and icons from an instance and upload it to the master.",
description: "Export the the locale and icons from an instance and upload it to the controller.",
});
definePermission({
name: "core.instance.extract_players",
@@ -553,13 +553,13 @@ definePermission({
definePermission({
name: "core.mod.list",
title: "List mods",
description: "Get the full list of mods stored on the master.",
description: "Get the full list of mods stored on the controller.",
grantByDefault: true,
});
definePermission({
name: "core.mod.search",
title: "Search mods",
description: "Search through the list of mods stored on the master.",
description: "Search through the list of mods stored on the controller.",
grantByDefault: true,
});
definePermission({
@@ -571,18 +571,18 @@ definePermission({
definePermission({
name: "core.mod.upload",
title: "Upload mod",
description: "Upload mods to the master.",
description: "Upload mods to the controller.",
});
definePermission({
name: "core.mod.download",
title: "Download mod",
description: "Download mods stored on the master.",
description: "Download mods stored on the controller.",
grantByDefault: true,
});
definePermission({
name: "core.mod.delete",
title: "Delete mod",
description: "Delete mods stored on the master.",
description: "Delete mods stored on the controller.",
});
definePermission({
@@ -687,7 +687,7 @@ definePermission({
definePermission({
name: "core.debug.dump_ws",
title: "Dump WebSocket",
description: "Dump all WebSocket communicatation from the master.",
description: "Dump all WebSocket communicatation from the controller.",
});
module.exports = {