From 5dac0fe8ceb4729387caeac275e4d97ea6399310 Mon Sep 17 00:00:00 2001 From: MagicalCodeMonkey Date: Sat, 14 Mar 2020 01:53:48 -0400 Subject: [PATCH 1/4] Update to SettingsHelper - Include new fields - Provide some additional output --- SettingsHelper.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/SettingsHelper.js b/SettingsHelper.js index 973fc705..8d410a76 100644 --- a/SettingsHelper.js +++ b/SettingsHelper.js @@ -22,7 +22,7 @@ module.exports = function () { { local: 'serverroot', env: 'SERVER_ROOT', - default: '' + default: '/slserver' }, { local: 'server_port', @@ -48,9 +48,19 @@ module.exports = function () { local: 'autoJoinPassword', env: 'AUTOJOIN_PASSWORD', default: '' + }, + { + local: 'custom_server', + env: 'CUSTOM_SERVER', + default: '' + }, + { + local: 'servers', + env: 'SERVERS', + default: '' } ]; - // Load and export our settings in preference of ENV -> args + // Load and export our settings in preference of Args -> ENV -> Settings file -> Default const output = {}; for (let i = 0; i < fields.length; i++) { const setting = fields[i]; @@ -62,13 +72,20 @@ module.exports = function () { // Remove trailing slashes, if they exist if ((setting.local == 'webroot' || setting.local == 'accessUrl') && output[setting.local].endsWith("/")) { + console.log(`${setting.local}/${setting.env} should not end in '/'. Removing trailing slash(es) for you.`); output[setting.local] = output[setting.local].replace(/\/+$/, ""); } // Add leading slash, if not provided if (setting.local == 'webroot' && !output[setting.local].startsWith("/")) { + console.log(`${setting.local}/${setting.env} should always start with '/'. Adding the leading slash for you.`); // Make sure it starts with one leading slash output[setting.local] = `/${output[setting.local]}`; } + // Make sure 'webroot' and 'serverroot' aren't set to '/'. Revert to default if they do. + if ((setting.local == 'webroot' || setting.local == 'serverroot') && output[setting.local] == '/') { + console.log(`${setting.local}/${setting.env} cannot be set to '/'. Reverting to default: '${setting.default}'`); + output[setting.local] = setting.default; + } process.env[setting.local] = output[setting.local]; } //console.log('Our settings are', output) From 7e7adb9d3a00940e1c5a8357a63640d83c89dd61 Mon Sep 17 00:00:00 2001 From: MagicalCodeMonkey Date: Sat, 14 Mar 2020 02:04:59 -0400 Subject: [PATCH 2/4] Group fields by web/server --- SettingsHelper.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/SettingsHelper.js b/SettingsHelper.js index 8d410a76..1679f757 100644 --- a/SettingsHelper.js +++ b/SettingsHelper.js @@ -4,6 +4,7 @@ const settings = require('./settings.json'); module.exports = function () { const fields = [ + // Webapp settings { local: 'webroot', env: 'WEB_ROOT', @@ -19,16 +20,6 @@ module.exports = function () { env: 'WEB_ACCESSURL', default: '' }, - { - local: 'serverroot', - env: 'SERVER_ROOT', - default: '/slserver' - }, - { - local: 'server_port', - env: 'SERVER_PORT', - default: '8089' - }, { local: 'autoJoin', env: 'AUTOJOIN_ENABLED', @@ -58,6 +49,17 @@ module.exports = function () { local: 'servers', env: 'SERVERS', default: '' + }, + // Server settings + { + local: 'serverroot', + env: 'SERVER_ROOT', + default: '/slserver' + }, + { + local: 'server_port', + env: 'SERVER_PORT', + default: '8089' } ]; // Load and export our settings in preference of Args -> ENV -> Settings file -> Default From b62ec3b9e429213e04acb21fc734d87903c766bb Mon Sep 17 00:00:00 2001 From: MagicalCodeMonkey Date: Sat, 14 Mar 2020 02:10:50 -0400 Subject: [PATCH 3/4] Missed the authentication setting --- SettingsHelper.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SettingsHelper.js b/SettingsHelper.js index 1679f757..6f6dc8ec 100644 --- a/SettingsHelper.js +++ b/SettingsHelper.js @@ -40,6 +40,13 @@ module.exports = function () { env: 'AUTOJOIN_PASSWORD', default: '' }, + { + local: 'authentication', + env: 'AUTHENTICATION', + default: { + mechanism: 'none' + } + }, { local: 'custom_server', env: 'CUSTOM_SERVER', From 0bbdf6affc44d1d4553a05f6035fa809a0163a6f Mon Sep 17 00:00:00 2001 From: MagicalCodeMonkey Date: Sun, 15 Mar 2020 01:02:33 -0400 Subject: [PATCH 4/4] Fix a minor issue with slash detection --- SettingsHelper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SettingsHelper.js b/SettingsHelper.js index 6f6dc8ec..6f3948bd 100644 --- a/SettingsHelper.js +++ b/SettingsHelper.js @@ -85,7 +85,7 @@ module.exports = function () { output[setting.local] = output[setting.local].replace(/\/+$/, ""); } // Add leading slash, if not provided - if (setting.local == 'webroot' && !output[setting.local].startsWith("/")) { + if (setting.local == 'webroot' && output[setting.local].length > 1 && !output[setting.local].startsWith("/")) { console.log(`${setting.local}/${setting.env} should always start with '/'. Adding the leading slash for you.`); // Make sure it starts with one leading slash output[setting.local] = `/${output[setting.local]}`;