about summary refs log tree commit diff
path: root/modules/services
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2016-08-16 00:04:00 +0200
committeraszlig <aszlig@redmoonstudios.org>2016-08-16 00:04:00 +0200
commita820823edf4902f5d1e88541a83e54ed3332ea7a (patch)
tree381c4a9dd2a80190ece8e5d3765e8d333ebe61a7 /modules/services
parent4d02db3f2be204b6bd4450b07935dc8f989f1f00 (diff)
modules/starbound: Flesh out safeScripts options
I'm not sure whether this was a single setting in the configuration file
prior to Starbound version 1.0 but it has more settings now that affect
how those safety checks are performed.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules/services')
-rw-r--r--modules/services/starbound.nix53
1 files changed, 43 insertions, 10 deletions
diff --git a/modules/services/starbound.nix b/modules/services/starbound.nix
index 0058cda0..b7275593 100644
--- a/modules/services/starbound.nix
+++ b/modules/services/starbound.nix
@@ -35,12 +35,18 @@ let
     }) cfg.users;
 
     inherit (cfg)
-      allowAssetsMismatch maxPlayers maxTeamSize safeScripts serverName
-      serverFidelity;
+      allowAssetsMismatch maxPlayers maxTeamSize serverName serverFidelity;
 
     clearPlayerFiles = false;
     clearUniverseFiles = false;
 
+    safeScripts = cfg.safeScripts.enable;
+    scriptInstructionLimit = cfg.safeScripts.instructionLimit;
+    scriptInstructionMeasureInterval =
+      cfg.safeScripts.instructionMeasureInterval;
+    scriptProfilingEnabled = cfg.safeScripts.profiling.enable;
+    scriptRecursionLimit = cfg.safeScripts.recursionLimit;
+
     gameServerBind = cfg.bind;
     gameServerPort = cfg.port;
 
@@ -231,14 +237,41 @@ in {
       };
     } // mkListenerOptions "query server" 21025;
 
-    safeScripts = mkOption {
-      type = types.bool;
-      default = true;
-      # XXX: The description is just a guess and we need to find out what this
-      # really does.
-      description = ''
-        This is to make sure scripts can't call unsafe functions.
-      '';
+    safeScripts = {
+      enable = mkOption {
+        type = types.bool;
+        default = true;
+        description = ''
+          Enable certain limitations of LUA scripts.
+        '';
+      };
+
+      instructionLimit = mkOption {
+        type = types.int;
+        default = 10000000;
+        description = ''
+          The maximum amount of instructions a LUA function can have.
+        '';
+      };
+
+      instructionMeasureInterval = mkOption {
+        type = types.int;
+        default = 10000;
+        description = ''
+          The amount of milliseconds to wait between consecutive checks of the
+          <option>instructionLimit</option> on LUA scripts.
+        '';
+      };
+
+      recursionLimit = mkOption {
+        type = types.int;
+        default = 100;
+        description = ''
+          Maximum depth of recursion for LUA scripts.
+        '';
+      };
+
+      profiling.enable = mkEnableOption "LUA script profiling";
     };
 
     serverName = mkOption {