From b84c5b429369ebb5022e6b19b9fffdaa99143765 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Mon, 18 Jan 2021 08:17:14 +0100 Subject: [PATCH] Add common settings for Factorio servers Add settings of interest to server administrators that appear in server-settings.json to the factorio.settings config. This makes it easier to see which settings can be set there. --- docs/configuration.md | 8 ++++++++ packages/lib/config/definitions.js | 12 ++++++++---- packages/master/master.js | 27 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 185213a8..889a1eaa 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -5,6 +5,14 @@ Configuration Master Configuration -------------------- +### master.name + +Name of the cluster. Used to distinguish it from other clusters and is +prepended to the name of servers in the server list. + +Defaluts to "Your Cluster". + + ### master.database_directory Directory used to store cluster data to. Needs to be writeable by the diff --git a/packages/lib/config/definitions.js b/packages/lib/config/definitions.js index 3c453eb9..5c6fff11 100644 --- a/packages/lib/config/definitions.js +++ b/packages/lib/config/definitions.js @@ -11,6 +11,13 @@ const classes = require("./classes"); */ class MasterGroup extends classes.ConfigGroup { } MasterGroup.groupName = "master"; +MasterGroup.define({ + name: "name", + title: "Name", + description: "Name of the cluster", + type: "string", + initial_value: "Your Cluster", +}); MasterGroup.define({ name: "database_directory", title: "Database directory", @@ -262,10 +269,7 @@ FactorioGroup.define({ name: "settings", description: "Settings overridden in server-settings.json", type: "object", - initial_value: { - "tags": ["clusterio"], - "auto_pause": false, - }, + initial_value: {}, // See create instance handler in master. }); FactorioGroup.define({ name: "verbose_logging", diff --git a/packages/master/master.js b/packages/master/master.js index eff99e7c..c0e6a677 100755 --- a/packages/master/master.js +++ b/packages/master/master.js @@ -741,6 +741,33 @@ class ControlConnection extends BaseConnection { if (db.instances.has(instanceId)) { throw new libErrors.RequestError(`Instance with ID ${instanceId} already exists`); } + + // Add common settings for the Factorio server + let settings = { + "name": `${masterConfig.get("master.name")} - ${instanceConfig.get("instance.name")}`, + "description": `Clusterio instance for ${masterConfig.get("master.name")}`, + "tags": ["clusterio"], + "max_players": 0, + "visibility": { "public": true, "lan": true }, + "username": "", + "token": "", + "game_password": "", + "require_user_verification": true, + "max_upload_in_kilobytes_per_second": 0, + "max_upload_slots": 5, + "ignore_player_limit_for_returning_players": false, + "allow_commands": "admins-only", + "autosave_interval": 10, + "autosave_slots": 5, + "afk_autokick_interval": 0, + "auto_pause": false, + "only_admins_can_pause_the_game": true, + "autosave_only_on_server": true, + + ...instanceConfig.get("factorio.settings"), + }; + instanceConfig.set("factorio.settings", settings); + db.instances.set(instanceId, { config: instanceConfig, status: "unassigned" }); }