mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Added factorio.enable_script_commands
This commit is contained in:
1 parent
feb09a6fe0
commit
762212747e
7 files changed
+46
No files matched your search
@@ -14,6 +14,12 @@ import { exportData } from "./export";
|
||||
import type Host from "./Host";
|
||||
import BaseInstancePlugin from "./BaseInstancePlugin";
|
||||
|
||||
const scriptCommands = [
|
||||
"/cheat", "/editor",
|
||||
"/command", "/c",
|
||||
"/measured-command", "/mc",
|
||||
"/silent-command", "/sc"
|
||||
];
|
||||
|
||||
const instanceRconCommandDuration = new lib.Histogram(
|
||||
"clusterio_instance_rcon_command_duration_seconds",
|
||||
@@ -371,6 +377,16 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
|
||||
}
|
||||
|
||||
async sendRcon(message: string, expectEmpty = false, plugin = "") {
|
||||
if (
|
||||
!this.config.get("factorio.enable_script_commands")
|
||||
&& scriptCommands.find(cmd => message.startsWith(cmd))
|
||||
) {
|
||||
throw new Error(
|
||||
"Attempted to use script command while disabled. See config factorio.enable_script_commands.\n" +
|
||||
`Command: ${message}`
|
||||
);
|
||||
}
|
||||
|
||||
let instanceId = String(this.id);
|
||||
let observeDuration = instanceRconCommandDuration.labels(instanceId).startTimer();
|
||||
try {
|
||||
|
||||
@@ -319,6 +319,7 @@ export interface InstanceConfigFields {
|
||||
"factorio.player_online_autosave_slots": number;
|
||||
"factorio.mod_pack_id": number | null;
|
||||
"factorio.enable_save_patching": boolean;
|
||||
"factorio.enable_script_commands": boolean;
|
||||
"factorio.enable_whitelist": boolean;
|
||||
"factorio.enable_authserver_bans": boolean;
|
||||
"factorio.settings": Record<string, unknown>;
|
||||
@@ -427,6 +428,15 @@ export class InstanceConfig extends classes.Config<InstanceConfigFields> {
|
||||
type: "boolean",
|
||||
initialValue: true,
|
||||
},
|
||||
"factorio.enable_script_commands": {
|
||||
description:
|
||||
"Allows achievement breaking commands to be executed over rcon. " +
|
||||
"Required for Clusterio integrations and most plugins. " +
|
||||
"This does not prevent players using script commands.",
|
||||
restartRequired: true,
|
||||
type: "boolean",
|
||||
initialValue: true,
|
||||
},
|
||||
"factorio.enable_whitelist": {
|
||||
description: "Turn on whitelist for joining the server.",
|
||||
type: "boolean",
|
||||
|
||||
Reference in new issue
Block a user