From eb8df307ecf87b5072618144b94ea3c393d44c64 Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Tue, 3 Oct 2023 17:20:22 +0000 Subject: [PATCH] show server config for admins Signed-off-by: Simon Smith --- meshuser.js | 8 ++++++++ views/default.handlebars | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/meshuser.js b/meshuser.js index d81ca46f..6ca4fbe7 100644 --- a/meshuser.js +++ b/meshuser.js @@ -5292,6 +5292,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use 'serverclearerrorlog': serverCommandServerClearErrorLog, 'serverconsole': serverCommandServerConsole, 'servererrors': serverCommandServerErrors, + 'serverconfig': serverCommandServerConfig, 'serverstats': serverCommandServerStats, 'servertimelinestats': serverCommandServerTimelineStats, 'serverupdate': serverCommandServerUpdate, @@ -6504,6 +6505,13 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use fs.readFile(parent.parent.getConfigFilePath('mesherrors.txt'), 'utf8', function (err, data) { obj.send({ action: 'servererrors', data: data }); }); } + function serverCommandServerConfig(command) { + // Load the server config + var configFilePath = common.joinPath(parent.parent.datapath, (parent.parent.args.configfile ? parent.parent.args.configfile : 'config.json')); + if (userHasSiteUpdate()) + fs.readFile(configFilePath, 'utf8', function (err, data) { obj.send({ action: 'serverconfig', data: data }); }); + } + function serverCommandServerStats(command) { // Only accept if the "My Server" tab is allowed for this domain if (domain.myserver === false) return; diff --git a/views/default.handlebars b/views/default.handlebars index 4d5a609a..6ba6a786 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -574,6 +574,7 @@ +
@@ -2157,6 +2158,7 @@ QV('p2ServerActionsRestore', (siteRights & 4) && ((serverFeatures & 2) != 0)); QV('p2ServerActionsVersion', (siteRights & 16) && ((serverFeatures & 4) != 0)); QV('p2ServerActionsErrors', (siteRights & 16) && ((serverFeatures & 8) != 0)); + QV('p2ServerActionsConfig', (siteRights & 16) && ((serverFeatures & 8) != 0)); QV('MainMenuMyFiles', siteRights & 8); QV('LeftMenuMyFiles', siteRights & 8); if (((siteRights & 8) == 0) && (xxcurrentView == 5)) { setDialogMode(0); go(1); } @@ -2755,6 +2757,18 @@ } break; } + case 'serverconfig': { + if ((xxdialogMode == 2) && (xxdialogTag == 'MeshCentralServerConfig')) { + if (message.data == null) { + setDialogMode(2, "MeshCentral Server Config", 1, null, "Server has no config file."); + } else { + var x = '
' + EscapeHtml(message.data) + '
'; + x += '
'; + setDialogMode(2, "MeshCentral Server Config", 3, null, x); + } + } + break; + } case 'serverconsole': { p15consoleReceive('serverconsole', message.value); break; @@ -12612,6 +12626,14 @@ function server_showErrorsDlgEx() { meshserver.send({ action: 'serverclearerrorlog' }); } function d2CopyServerErrorsToClip() { saveAs(new Blob([Q('d2ServerErrorsLogPre').innerText], { type: 'application/octet-stream' }), "servererrors.txt"); } + function server_showConfigDlg() { + if (xxdialogMode) return false; + setDialogMode(2, "MeshCentral Config", 1, null, "Loading...", 'MeshCentralServerConfig'); + meshserver.send({ action: 'serverconfig' }); + return false; + } + function d2CopyServerConfigToClip() { saveAs(new Blob([Q('d2ServerConfigPre').innerText], { type: 'application/octet-stream' }), "config.json"); } + // // MY MESHS //