summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-03-27 22:36:40 +0200
committerTor Andersson <tor@ccxvii.net>2022-03-27 22:45:29 +0200
commitaa5bbfd04e85ea8a0c63fe9b8bd220a1898f70a7 (patch)
treeff920e02ad348e5c1726190825bd0fce512162e3 /server.js
parent2b71f3a51d694682c7fc6cb42d3197c958847fc3 (diff)
downloadserver-aa5bbfd04e85ea8a0c63fe9b8bd220a1898f70a7.tar.gz
Enable/disable debugging commands as a global server setting.
Diffstat (limited to 'server.js')
-rw-r--r--server.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/server.js b/server.js
index 9342d80..b38c368 100644
--- a/server.js
+++ b/server.js
@@ -12,6 +12,8 @@ const sqlite3 = require('better-sqlite3');
require('dotenv').config();
+let DEBUG = process.env.DEBUG || 0;
+
let HTTP_PORT = process.env.HTTP_PORT || 8080;
let HTTPS_PORT = process.env.HTTPS_PORT;
@@ -1698,6 +1700,8 @@ function on_chat(socket, message) {
}
function on_debug(socket) {
+ if (!DEBUG)
+ send_message(socket, 'error', "Debugging is not enabled on this server.");
SLOG(socket, "DEBUG");
try {
let game_state = SQL_SELECT_GAME_STATE.get(socket.game_id);
@@ -1711,6 +1715,8 @@ function on_debug(socket) {
}
function on_save(socket) {
+ if (!DEBUG)
+ send_message(socket, 'error', "Debugging is not enabled on this server.");
SLOG(socket, "SAVE");
try {
let game_state = SQL_SELECT_GAME_STATE.get(socket.game_id);
@@ -1724,6 +1730,8 @@ function on_save(socket) {
}
function on_restore(socket, state_text) {
+ if (!DEBUG)
+ send_message(socket, 'error', "Debugging is not enabled on this server.");
SLOG(socket, "RESTORE");
try {
let state = JSON.parse(state_text);
@@ -1749,6 +1757,8 @@ function broadcast_presence(game_id) {
}
function on_restart(socket, scenario) {
+ if (!DEBUG)
+ send_message(socket, 'error', "Debugging is not enabled on this server.");
try {
let seed = random_seed();
let options = JSON.parse(SQL_SELECT_GAME.get(socket.game_id).options);